Message 1 of 17
Run Rule on all open drawings
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I have the below rule to print PDFs of all open drawings.
This works perfect but I would like to be able to run an external rule on each drawing before the PDF is made.
Can anyone help me out please.
I run 2014
SyntaxEditor Code Snippet
Dim oDoc As Inventor.Document For Each oDoc In ThisApplication.Documents.VisibleDocuments If (oDoc.documenttype = kDrawingDocumentObject) Then 'Found a drawing 'find the postion of the last backslash in the path oFNamePos = InStrRev(oDoc.fullfileName, "\", -1) 'get the file name with the file extension oName = Right(oDoc.fullfileName, Len(oDoc.fullfileName) - oFNamePos) 'get the path of the folder containing the file oPath = Left(oDoc.fullfileName, Len(oDoc.fullfileName) - Len(oName)) 'get the file name (without extension) oRevNum = oDoc.PropertySets("Inventor Summary Information")("Revision Number").Value If oRevNum <> 0 Then oShortName = Left(oName, Len(oName) - 4) & " - Rev " & oRevNum Else oShortName = Left(oName, Len(oName) - 4) End If oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'oOptions.Value("All_Color_AS_Black") = 0 'oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 600 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 = oPath & "\PDF" '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 & "\" & oShortName & ".pdf" On Error Goto handlePDFLock 'Publish document oPDFAddIn.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium) End If Next oDoc 'Show message box MessageBox.Show("PDF(s) exported to: " & oFolder , "iLogic") '-------------------------------------------------------------------------------- Exit Sub handlePDFLock:MessageBox.Show("At least one PDF could not be saved, " _ & "most likely someone else has it open.", _ "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!") Resume Next