
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I am working on revising code I have found online that will take a multi-sheet drawing file and export each sheet to its own PDF using the sheet names as the PDF names. I have found many ways to do this, but we use .dwg drawing files instead of .idw drawing files. Whenever I run the code listed below, I get empty 0 byte files named after the sheet names. Inside the "For Each" command I revised the original code from "idw" to "dwg". The rule opens any related .dwg files which is great, but instead of creating a PDF at that point, it creates the 0 byte file.
I have been working with inventor for just a few months now, so I am hoping that someone can spot something that I am completely missing.
Link to code source:
https://forums.autodesk.com/t5/inventor-forum/export-multiple-sheets-to-separate-pdf-s/td-p/8303860
'['Sub Variables oRefDocs = ThisApplication.ActiveDocument.AllReferencedDocuments Dim oDoc As Document oFolder = ThisDoc.Path oPDFLOC = "G:\PDFS\" oAddIns = ThisApplication.ApplicationAddIns oTG = ThisApplication.TransientObjects'] '['PDF Export '['PDF Options oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = oTG.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = oTG.CreateNameValueMap oDataMedium = oTG.CreateDataMedium oOptions.Value("All_Color_AS_Black") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 4800 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet'] For Each oDoc In oRefDocs dwgPathName = Left(oDoc.FullDocumentName, Len(oDoc.FullDocumentName) -3) & "dwg" '(I changed from idw to dwg) If System.IO.File.Exists(dwgPathName) Then oDrawDoc = ThisApplication.Documents.Open(dwgPathName, True) For Each oSheet As Sheet In oDrawDoc.Sheets oSheet.Activate oDataMedium.FileName = oPDFLOC + oSheet.Name + ".pdf" oPDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium) Next oDrawDoc.Close(True) End If Next'] MessageBox.Show("PDF Export completed.", "PDF Export", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Thanks,
ndelaughter
Solved! Go to Solution.