Message 1 of 20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a rule that exports to pdf and ad adds the date to the end of the file so I can keep track of changes. I have run into an issue when I export for the first time that day it overrides the previous date. But when I run the rule again it will update the date and export properly. Is there something in Inventor that needs to be updated before running the rule?
Most of this rule has been copy pasted from other rules on the forums to piece together what I need.
SyntaxEditor Code Snippet
'Get Date and Format Dim Time As DateTime = DateTime.Now Dim Format As String = "yyyy.M.d" Dim oPropSet As PropertySet oPropSet = _ ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") Try 'try to get the iproperty value oTest = iProperties.Value("Custom", "DateTimeString") Catch 'catch error when iproperty doesn't exist and create it oPropSet.Add("", "DateTimeString") End Try oDate = iProperties.Value("Custom", "DateTimeString") oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("project", "revision number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'then set the property iProperties.Value("Custom", "DateTimeString") = Time.ToString(Format) If oPDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = ThisDoc.Path 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & " - " & oDate & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '------end of iLogic------- InventorVb.DocumentUpdate()
Thanks for the help.
Solved! Go to Solution.