Save multisheet as multiple .pdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all!
Upon thoroughly searching online for a direct solution and finding nothing, I started combining lines of code to meet my goals.
I want to save a multisheet drawing to PDF, but each sheet separately and with its own name.
I already have a code thats renames the sheet to match the object in its first view and places the revision as well (Eg.: Solid with the name "Part1" is the first view in the drawing and has revision "0", so the sheet renames from "Sheet1" to "Part1.0").
The destination folder of the .pdf is the same as the drawing document;
The line of code should be able to save all sheets in one go, without needing to run it individually in each sheet;
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc As DrawingDocument = ThisDoc.Document For Each dwgSheet As Sheet In dwgDoc.Sheets If dwgSheet.DrawingViews.Count > 0 Then modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument 'get the part number of the part in view prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value 'get the part revision number Rev = modelDoc.PropertySets.Item("Summary Information").Item("Revision Number").Value oPath = ThisDoc.Path oFileName = prtNumber oRevNum = Rev oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = modelDoc 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") = 1 oOptions.Value("Remove_Line_Weights") = 1 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet 'oOptions.Value("Custom_Begin_Sheet") = 2 'oOptions.Value("Custom_End_Sheet") = 4 End If 'get PDF target folder path oFolder = oPath 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & "." & oRevNum & ".pdf" 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End If Next End If End Sub
I get this error when I run it:
Any ideas how to make this work?
João Silva
Mechanical Engineer