Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Little help please. I would like to export pdf in monochrome. This is my ilogic.
Sub Main () FileName = ThisDoc.FileName(True) 'with extension FileExtension = Right(FileName, 3) If FileExtension = "idw" Then Save_As_PDF Else If FileExtension = "dwg" Then Save_As_PDF Else ErrorMessage End If End Sub Sub Save_As_PDF oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 'Gets the Workspace Path WorkspacePath= ThisDoc.WorkspacePath() 'Gets the Length of the WorkspacePath String WorkspacePathLength = Len(WorkspacePath) 'Gets just the Path of the file PathOnly = ThisDoc.Path 'Removes the Workspace Path from FullPath DirectoryPath = Strings.Right(PathOnly, PathOnly.Length-WorkspacePathLength) 'Find Referenced Document Dim oRefDocFile As Document If ThisDoc.ModelDocument IsNot Nothing Then oRefDocFile = ThisDoc.ModelDocument Else MessageBox.Show("No Referenced Document","Error") Return End If 'format model file name Dim FNamePos As Long FNamePos = InStrRev(oRefDocFile.FullFileName, "\", -1) Dim oRefDocName As String oRefDocName = Right(oRefDocFile.FullFileName, Len(oRefDocFile.FullFileName) - FNamePos) 'Obtain referenced document revision oRevision = iProperties.Value(oRefDocName, "Project", "Revision Number") oDescription = iProperties.Value(oRefDocName, "Project", "Description") oTitle = iProperties.Value(oRefDocName, "Summary", "Title") 'Sets the Dirctory that the PDF should be saved in PDFPath = "D:\Vault\Designs\" & DirectoryPath PDFName = PDFPath & "\" & oDescription & " " & oRevision & "-" & oTitle & ".pdf" 'Set the PDF target file name oDataMedium.FileName = PDFName oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets 'Checks to see if that directory exists, if not, it is created If(Not System.IO.Directory.Exists(PDFPath)) Then System.IO.Directory.CreateDirectory(PDFPath) End If 'Saves the PDF in the desired location oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) End Sub Sub ErrorMessage i = MessageBox.Show("This is not a drawing file. No PDF will be created.", "Create PDF", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) End Sub
Solved! Go to Solution.