Export 3DPDF using Anark does not seem to work with C# language

Export 3DPDF using Anark does not seem to work with C# language

montanceslouis
Explorer Explorer
378 Views
2 Replies
Message 1 of 3

Export 3DPDF using Anark does not seem to work with C# language

montanceslouis
Explorer
Explorer

Hello and Good day,

 

I'm using C# and trying to invoke the api for exporting 3dpdf using Anark Core, but i'm having this error at "pdfConvertor3d.Publish(oDoc, oOptions);" please see image below:

montanceslouis_0-1658472285820.png

 

The code provided from your API help was working fine using Visual Basic.

Is there a direct Inventor API to do 3dpdf export? The 3rd party app Anark don't seem to work using C#, not so sure.

 

Thank you! in advance for your feedback.

 

0 Likes
379 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

I don't think the problem is C#. In the help files, there is a C# example on how to export 3D pdf files.

public void Export3DPdf()
        {
            Inventor.Application InvApp = mApp;

            Inventor.ApplicationAddIn  PDFAddin = null ;

            foreach (ApplicationAddIn appAddin in mApp.ApplicationAddIns )
            {
                if (appAddin.ClassIdString == "{3EE52B28-D6E0-4EA4-8AA6-C2A266DEBB88}")
                {
                    PDFAddin =  appAddin;
                    break;
                }
            }

            dynamic pdfConvertor3d = PDFAddin.Automation;

            Document oDoc = mApp.ActiveDocument;
            // Create a NameValueMap object
            Inventor.NameValueMap oOptions = InvApp.TransientObjects.CreateNameValueMap();
            
            oOptions.Value["FileOutputLocation"] = @"c:\temp\3DPDF.pdf";
            oOptions.Value["ExportAllProperties"] = true;
            oOptions.Value["GenerateAndAttachSTEPFile"] = true ;
            oOptions.Value["ExportTemplate"] = @"C:\Users\Public\Documents\Autodesk\Inventor 2019\Templates\Sample Part Template.pdf";
            oOptions.Value["VisualizationQuality"] = AccuracyEnum.kHigh;

            //string[] sProps = new string[1];
            //sProps[0] = "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}:Title";
            //oOptions.Value["ExportAllProperties"] = false; 
            //oOptions.Value["ExportProperties"] = sProps;

            String[] sDesignViews = new string[] { "Master", "View1" }; 
            oOptions.Value["ExportDesignViewRepresentations"] = sDesignViews;

            pdfConvertor3d.Publish(oDoc, oOptions);

        }

In your code, I see some other options. Maybe one of those is the problem. Can you try to use only the options that are also in the help file?

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 3

montanceslouis
Explorer
Explorer

Thank you for your input.

 

Yes, this code works fine on standalone project. As well as the visual basic.
But on over the Addin, the C# code is not working, only the visual basic.
By the way, the project that i'm doing is a separate addin for Inventor.

Thanks again, JelteDeJong

0 Likes