Before save ilogic. trigger after file location

Before save ilogic. trigger after file location

Darkforce_the_ilogic_guy
Advisor Advisor
186 Views
1 Reply
Message 1 of 2

Before save ilogic. trigger after file location

Darkforce_the_ilogic_guy
Advisor
Advisor

I would like to get a code that change an properties  using before save. 

 

but the problem is that what I can think of that I can use as trigger are part number or save location.  but even though I select both is kind of selected before the ilogic code seens to run .. I can´t see this informationi before I save the second time. is there a  way to get the location that is will save the file in or the part number  to use in before save ? 

 

we are using numbering scchemens in vault to give the file it number filename always = part number

0 Likes
187 Views
1 Reply
Reply (1)
Message 2 of 2

Ralf_Krieg
Advisor
Advisor

Hello

 

AFAIK no, there's no way to get this informations. The file name number is generated right on save.

On possible way is to use the AfterSaveDcoument event trigger and if the document.filesavecounter = 1, the file was saved for the first time and fill up the properties. Right after this a second save should be done.

I don't know what happens if the first save is on closing the document or if an assembly is recursively saved. Needs to be tested.

 

If ThisDoc.Document.DocumentType = DocumentTypeEnum.kPartDocumentObject Or ThisDoc.Document.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
	Dim oDoc As Document = ThisDoc.Document
	Dim oUserPropSet As PropertySet = oDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") 'User defined properties
	Dim oDocPropSet As PropertySet = oDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Design Tracking Properties
	Dim oProp As Inventor.Property
	
	If oDoc.FileSaveCounter = 1 Then
		Logger.Debug("First save")
		Try
			oUserPropSet.Add(oDocPropSet.Item("Part Number").Value, "PRTNBR")
			oDoc.Save 
		Catch
			Logger.Debug("Adding Prop failed")
		End Try
	Else
		Logger.Debug("Not first save")
	End If
End If

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes