Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I have my script like below, but I'm getting still all sheet/pages exported instead of the current:
BASICALLY I want only first page for DWG... (but I can't find where to set PrintRangeEnum to a value - I can find only examples for PrintManager)
Code:
Dim oDoc As Document Dim doDWG, doPDF As Boolean vbBoxQuestion = MessageBox.Show("Export DWGs?" & vbLf & vbLf & "Cancel to Eport DWGs without PDFs", "EXPORT PDF AND DWG FOR ALL OPENED DOCUMENTS", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) If vbBoxQuestion = vbYes Then doDWG = True doPDF = True Else If vbBoxQuestion = vbCancel Then doDWG = True doPDF = False Else doDWG = False doPDF = True End If '[ for PDF export: Dim oPDFAddIn As TranslatorAddIn oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oPDFOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMediumPDF = ThisApplication.TransientObjects.CreateDataMedium 'set PDF Options Dim PDFExportFilename As String = ".pdf" 'If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 'If oPDFAddIn.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then oPDFOptions.Value("All_Color_AS_Black") = 0 oPDFOptions.Value("Remove_Line_Weights") = 0 oPDFOptions.Value("Vector_Resolution") = 300 oPDFOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'End If '] For PDF export: '[ for DWG export: Dim DWGExportFilename As String = ".dwg" Dim oDWGAddIn As TranslatorAddIn oDWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}") Dim oDataMediumDWG As DataMedium oDataMediumDWG = ThisApplication.TransientObjects.CreateDataMedium oDWGOptions = ThisApplication.TransientObjects.CreateNameValueMap oDWGOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet '] for DWG export: For Each oDoc In ThisApplication.Documents If oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then Dim fileNameCore As String = Left(oDoc.FullDocumentName, oDoc.FullDocumentName.Length-4) 'Set the PDF target file name If doPDF = True Then oDataMediumPDF.FileName = fileNameCore & PDFExportFilename Logger.Trace(fileNameCore & PDFExportFilename) End If If doDWG = True Then oDataMediumDWG.FileName = fileNameCore & DWGExportFilename Logger.Trace(fileNameCore & DWGExportFilename) End If Try 'Publish document If doPDF = True Then oPDFAddIn.SaveCopyAs(oDoc, oContext, oPDFOptions, oDataMediumPDF) End If If doDWG = True Then oDWGAddIn.SaveCopyAs(oDoc, oContext, oDWGOptions, oDataMediumDWG) End If Catch MessageBox.Show("Error writing out file", "iLogic") bError = True End Try End If Next MessageBox.Show("Done.", "Exporting")
-------------------------
Tomasz Malinowski
Tomasz Malinowski
Solved! Go to Solution.