Output Mono or Colour PDF file Using Inventor VBA

Output Mono or Colour PDF file Using Inventor VBA

isocam
Collaborator Collaborator
375 Views
1 Reply
Message 1 of 2

Output Mono or Colour PDF file Using Inventor VBA

isocam
Collaborator
Collaborator

Can anybody help?

 

I have a VBA macro that can output a PDF file of a Inventor Drawing (idw or dwg) OK

 

What I want to do is output a detail drawing in "black & white" (Mono) and output a assembly drawing in colour.

 

Does anybody know if it is possible using inventor VBA and does anybody have an example how to do this???

 

Many thanks in advance!

 

Darren

0 Likes
376 Views
1 Reply
Reply (1)
Message 2 of 2

basnederveen
Advocate
Advocate
Public Sub PublishPDF()
    ' Get the PDF translator Add-In.    Dim PDFAddIn As TranslatorAddIn
    Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

    'Set a reference to the active document (the document to be published).
    Dim oDocument As Document
    Set oDocument = ThisApplication.ActiveDocument

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    oContext.Type = kFileBrowseIOMechanism

    ' Create a NameValueMap object    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

    ' Create a DataMedium object
    Dim oDataMedium As DataMedium
    Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

    ' Check whether the translator has 'SaveCopyAs' options    If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

        ' Options for drawings...

        oOptions.Value("All_Color_AS_Black") = 0 ' change to one for black and white

        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Sheet_Range") = kPrintAllSheets
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4    End If

    'Set the destination file name
    oDataMedium.FileName = "c:\temp\test.pdf"

    'Publish document.    Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub

You can make either a button for B&W and one for color, or create a script which recognizes if a view in the first sheet is referencing and assembly or a part.

 

btw this is taken directly from the samples, you can look in the help function in inventor for this

0 Likes