Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using iLogic to publish PDFs to multiple directories

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
peter.rewinskiP3KTC
427 Views, 5 Replies

Using iLogic to publish PDFs to multiple directories

peter.rewinskiP3KTC
Participant
Participant

I'm using Inventor and Vault 2023, and my workspace is based on my C: drive. The company I work for uses a network drive (common NAS device) as well to access engineering documents. Is there a way to set up iLogic triggers or rules where when I publish a PDF to my C: drive, it publishes to our M: drive (network drive from above) as well? Are there any tools in the Vault job processor that would aid in this? Should I just bite the bullet and take the few extra keystrokes to publish to multiple drives or copy/paste my drawings over instead of trying to automate this task? Any suggestions or alternatives would be appreciated! Thanks! 

Using iLogic to publish PDFs to multiple directories

I'm using Inventor and Vault 2023, and my workspace is based on my C: drive. The company I work for uses a network drive (common NAS device) as well to access engineering documents. Is there a way to set up iLogic triggers or rules where when I publish a PDF to my C: drive, it publishes to our M: drive (network drive from above) as well? Are there any tools in the Vault job processor that would aid in this? Should I just bite the bullet and take the few extra keystrokes to publish to multiple drives or copy/paste my drawings over instead of trying to automate this task? Any suggestions or alternatives would be appreciated! Thanks! 

Labels (5)
5 REPLIES 5
Message 2 of 6

dalton98
Collaborator
Collaborator

I like to use the api control definition commands instead of iLogic when exporting pdf's. Here is an example:

You can make it an event trigger 'After Save' and it works too.

Dim oName As String = ThisDrawing.Name & ".pdf"

Dim oCmd As ControlDefinition
oCmd = ThisApplication.CommandManager.ControlDefinitions.Item("AppFileExportPDFCmd")

cfilelocation = "C:\temp\"
mfilelocation = "M:\Folder1\"
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, cfilelocation & oName)
oCmd.Execute     

 

0 Likes

I like to use the api control definition commands instead of iLogic when exporting pdf's. Here is an example:

You can make it an event trigger 'After Save' and it works too.

Dim oName As String = ThisDrawing.Name & ".pdf"

Dim oCmd As ControlDefinition
oCmd = ThisApplication.CommandManager.ControlDefinitions.Item("AppFileExportPDFCmd")

cfilelocation = "C:\temp\"
mfilelocation = "M:\Folder1\"
ThisApplication.CommandManager.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, cfilelocation & oName)
oCmd.Execute     

 

Message 3 of 6

Michael.Navara
Advisor
Advisor

You can use any iLogic rule for export to PDF. Setup the output to your C:\ drive and later on copy the file to M:\

Something like this code snippet

Sub Main()
    CADS_PubblishPDF()
End Sub

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

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

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

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

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

    oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets

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

        ' Options for drawings...
        oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
        oOptions.Value("All_Color_AS_Black") = 0
        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4

    End If

    ' the destination file name
    Dim pdfFileNameLocal = ThisDoc.PathAndFileName(False) & ".pdf"
    oDataMedium.FileName = pdfFileNameLocal

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

    'Copy file to Network drive
    Dim pdfFileNameOnNetworkDrive = "M:\" & ThisDoc.FileName(False) & ".pdf"
    System.IO.File.Copy(pdfFileNameLocal, pdfFileNameOnNetworkDrive)
End Sub

You can use any iLogic rule for export to PDF. Setup the output to your C:\ drive and later on copy the file to M:\

Something like this code snippet

Sub Main()
    CADS_PubblishPDF()
End Sub

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

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

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

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

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

    oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets

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

        ' Options for drawings...
        oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
        oOptions.Value("All_Color_AS_Black") = 0
        'oOptions.Value("Remove_Line_Weights") = 0
        'oOptions.Value("Vector_Resolution") = 400
        'oOptions.Value("Custom_Begin_Sheet") = 2
        'oOptions.Value("Custom_End_Sheet") = 4

    End If

    ' the destination file name
    Dim pdfFileNameLocal = ThisDoc.PathAndFileName(False) & ".pdf"
    oDataMedium.FileName = pdfFileNameLocal

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

    'Copy file to Network drive
    Dim pdfFileNameOnNetworkDrive = "M:\" & ThisDoc.FileName(False) & ".pdf"
    System.IO.File.Copy(pdfFileNameLocal, pdfFileNameOnNetworkDrive)
End Sub
Message 4 of 6

peter.rewinskiP3KTC
Participant
Participant

Thanks for the reply. I don't have the API tools installed on my machine currently- do you use developer or user tools to execute the code you're suggesting? 

0 Likes

Thanks for the reply. I don't have the API tools installed on my machine currently- do you use developer or user tools to execute the code you're suggesting? 

Message 5 of 6

Michael.Navara
Advisor
Advisor
Accepted solution

No, this is just iLogic rule. You don't need to install anything special

0 Likes

No, this is just iLogic rule. You don't need to install anything special

Message 6 of 6

peter.rewinskiP3KTC
Participant
Participant

Thanks for the help! Looking forward to trying some of this out. 

0 Likes

Thanks for the help! Looking forward to trying some of this out. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report