Sunday, December 31, 2017
iLogic Batch Output PDFs from an Assembly File
iLogic Batch Output PDFs from an Assembly File
Issue:
Youd like to output a PDF file from the drawings of all the components found in an assembly file (if those components have a drawing file created), and you like also create a PDF of the top level assembly drawing as well. All of these PDFs should be written out to a single folder. Can this be done?
Solution:
Heres an ilogic rule to batch output PDF files for each component in an assembly. This rule assumes that the component drawings share the same name and location of the component.
For example: C:Tempwidget-450.ipt has a drawing: C:Tempwidget-450.idw
If the drawing file is not found, then it simply moves on and looks at the next component.
This rule may not work for everyone, but it should provide a starting point from which it can be modified as needed. If you work with *.dwg files rather than *.idw files you can search and replace this code for idw and replace with dwg.
Here is the code in a *.txt file that can be downloaded as well:
http://forums.autodesk.com/autodesk/attachments/autodesk/78/455124/2/Batch%20PDFs.txt
define the active document as an assembly file
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) -4)
check that the active document is an assembly file
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
get user input
RUsure = MessageBox.Show ( _
"This will create a PDF file for all of the asembly components that have drawings files." _
& vblf & "This rule expects that the drawing file shares the same name and location as the component." _
& vblf & " " _
& vblf & "Are you sure you want to create PDF Drawings for all of the assembly components?" _
& vblf & "This could take a while.", "iLogic - Batch Output PDFs ",MessageBoxButtons.YesNo)
If RUsure = vbNo Then
Return
Else
End If
- - - - - - - - - - - - -PDF setup - - - - - - - - - - - -
oPath = ThisDoc.Path
PDFAddIn = 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 PDFAddIn.HasSaveCopyAsOptions(oDataMedium, link download