PDF export ilogic - monochrome

PDF export ilogic - monochrome

pbartosinski
Enthusiast Enthusiast
693 Views
3 Replies
Message 1 of 4

PDF export ilogic - monochrome

pbartosinski
Enthusiast
Enthusiast

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 
0 Likes
Accepted solutions (1)
694 Views
3 Replies
Replies (3)
Message 2 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

have a look at this post. I think you are looking for the option:

oOptions.Value("All_Color_AS_Black") = True

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 4

Anonymous
Not applicable

Offtopic, but I am quite concerned when Reshala is asking about ilogic.. 🙂

0 Likes
Message 4 of 4

pbartosinski
Enthusiast
Enthusiast

Even Reshala has some other hobbies than waiting on gas sation or doorms an killing people 😉