creating 3d pdf with API and C#.NET

creating 3d pdf with API and C#.NET

Anonymous
Not applicable
2,982 Views
5 Replies
Message 1 of 6

creating 3d pdf with API and C#.NET

Anonymous
Not applicable

Hello,

 

our company has just updated to Inventor 2017 to export some Assembly/Part to 3D PDF.

Now we are now trying to integrate the 3D PDF export in a own developed software with c#.net.

But we have encountered a minor problem and we need support from developpers.

 

In the help file of the api in Inventor 2017 there is a api sample for “Export to 3D PDF API Sample” in VBA (see below in green)

 

When trying the same in C#.NET we have the problem that following code will not compile.

The pdfConvertor3d.Publish will not work because of the definition of pdfConvertor3d as object.

What class/interface should we cast TranslatorAddIn.Automation!

Do you have a sample code in C#.NET for the export of 3d pdf like below?

 

 

TranslatorAddIn pdf3dAddIn = (TranslatorAddIn)iApp.ApplicationAddIns.ItemById["{3EE52B28-D6E0-4EA4-8AA6-C2A266DEBB88}"];

object pdfConvertor3d = pdf3dAddIn.Automation; //pdf3dAddIn.Automation returns an object or what class should we cast it?

 

//…

     

//Publish document

pdfConvertor3d.Publish(idoc, oOptions); //Publish is not valid!

 

 

 

 

Export to 3D PDF API Sample (VBA) of the API Help

 

Public Sub PublishTo3DPDF()

    ' Get the 3D PDF Add-In.

    Dim oPDFAddIn As ApplicationAddIn

    Dim oAddin As ApplicationAddIn

    For Each oAddin In ThisApplication.ApplicationAddIns

        If oAddin.ClassIdString = "{3EE52B28-D6E0-4EA4-8AA6-C2A266DEBB88}" Then

            Set oPDFAddIn = oAddin

            Exit For

        End If

    Next

   

    If oPDFAddIn Is Nothing Then

        MsgBox "Inventor 3D PDF Addin not loaded."

        Exit Sub

    End If

   

    Dim oPDFConvertor3D

    Set oPDFConvertor3D = oPDFAddIn.Automation

   

    'Set a reference to the active document (the document to be published).

    Dim oDocument As Document

    Set oDocument = ThisApplication.ActiveDocument

   

    ' Create a NameValueMap object as Options

    Dim oOptions As NameValueMap

    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

 

    ' Options

    oOptions.Value("FileOutputLocation") = "c:\temp\test.pdf"

    oOptions.Value("ExportAnnotations") = 1

    oOptions.Value("ExportWokFeatures") = 1

    oOptions.Value("GenerateAndAttachSTEPFile") = True

    oOptions.Value("VisualizationQuality") = kHigh

   

    ' Set the properties to export

    Dim sProps(0) As String

    sProps(0) = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}:Title"  ' Title

   

    oOptions.Value("ExportAllProperties") = False

    oOptions.Value("ExportProperties") = sProps

 

    ' Set the design views to export

    Dim sDesignViews(1) As String

    sDesignViews(0) = "Master"

    sDesignViews(1) = "View1"

   

    oOptions.Value("ExportDesignViewRepresentations") = sDesignViews

   

    'Publish document.

    Call oPDFConvertor3D.Publish(oDocument, oOptions)

End Sub

 

 

Regards

Enzo Naso    

0 Likes
2,983 Views
5 Replies
Replies (5)
Message 2 of 6

c_hoppen
Advocate
Advocate

Is there no solution? I also need to export 3d pdf using c# .net.

0 Likes
Message 3 of 6

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Just use dynamic:

dynamic pdfConvertor3d = pdf3dAddIn.Automation;

Cheers,



Adam Nagy
Autodesk Platform Services
Message 4 of 6

c_hoppen
Advocate
Advocate

No No No thats too easy! Impossible! 😉

 

Thanks

Christoph

0 Likes
Message 5 of 6

YuhanZhang
Autodesk
Autodesk

Declare the variable using 'dynamic' does work. Attached a sample C# project for this, you can open a part/assembly and run the code to check the result. You may need to modify the sDesignViews array to specify proper values for it before running it.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 6 of 6

jmacapagal2CD9H
Contributor
Contributor

Hello, just came here to ask about the same problem but I am using the same code from a custom Addin that I created. I got this error when publishing. It is working If I use it on a external application.

jmacapagal2CD9H_0-1656985812337.png