Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: 4thAxis

Just some thoughts but...  Tt seems to me that the file name is generally written to the Part Number iProperty on 'initial' save only, then it does not do that anymore after that point.  If that is the case, then I do believe we can use an iLogic rule for this.  However, I think we would need to utilize the 'After Save' Event Trigger, instead of before, so that the action has already taken place, so that we can correct it.  Then to limit the rule to only work on the document on the first save, then not any more after that, I believe we can use the Document.FileSaveCounter property.  It should return zero, if it has not been saved before, and 1 at first save, then will always be more than one.  So, if that property returns 1, run our code to clear the Part Number value.  Then any additional times you save that document, the rule will still be triggered to run by the Event Triggers, but it will not do anything to the document.

 

oDoc = ThisDoc.Document
If oDoc.FileSaveCounter = 1 Then
	Dim oPNProp As Inventor.Property = oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number")
	Dim oPN As String = oPNProp.Value
	If oPN <> "" Then oPNProp.Value = ""
	If oPNProp.Dirty Then 'Dirty = has been changed to since last save
		oDoc.Save
	End If
End If

 

Even this might possibly be risky though, if you commonly write something to that Part Number iProperty before it is saved for the first time.  With the solution above, that data may be lost.

 

If you want to be able to preserve any data that may have already been in the Part Number iProperty before the initial save, then I would propose a second iLogic rule that will be triggered to run 'Before Save', and only does something when FileSaveCounter = 0, and gets the current value of the Part Number iProperty.  If it is empty, then don't do anything else.  If it is not empty, record its value to a SharedVariable.  Then edit this rule above to check if that SharedVariable.Exists(), and if it does, get the value from it.  If the current Part Number values (after initial save) does not match what was recorded (before initial save), then overwrite it with the value from before save.  Then, only if those actions took place, get rid of the SharedVariable, to clean up.

 

Correction:  If you have written something to the Part Number iProperty prior to initial save, then when you save it for the first time, it will not overwrite that pre-existing Part Number value.  But if the Part Number iProperty was empty when you initially save it, it will fill it in with the file name automatically.  So, putting a default or placeholder type value in there for the Part Number iProperty value may prevent this unwanted behavior altogether.  (behavior tested in Inventor 2022)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)