Sorting “invalid arguments” error in C# add in code for generating 3D PDF in Inventor

<?xml encoding=”UTF-8″>The VB.NET add-in for 3D PDF generation works well and directly without issues. However, the C# API code throws an invalid arguments error at the Publish() method. This is because the code uses late binding.  This blog contains steps on how to resolve this error

Step 1:
As mentioned in this blog (here) set the Embed Interop Type to False under the Inventor Interop Assembly reference

Embed

Step 2:
Add the Microsoft.CSharp reference to your project then import the namespace in the code

Reference

 

Step 3:
Declare the PDF converter 3D ApplicationAddin Variable as dynamic as seen below
dynamic oPDFConvertor3D ;
oPDFConvertor3D = oPDFAddIn.Automation;

Step 4:
The Publish() method takes two arguments, the first is of type Inventor document and the second is of Inventor NameValueMap type. Declare the variable of the type document as dynamic before parsing it to the method.

See the sample code below

dynamic oDocument;
oDocument = m_inventorApplication.ActiveDocument;

These steps should be able to resolve the error.

  • Fidel

Comments

One response to “Sorting “invalid arguments” error in C# add in code for generating 3D PDF in Inventor”

  1. I just finished looking for this information for a while now. After nonstop searching for it on Google for the past six hours, I was finally successful in finding it on your website. I am perplexed as to why Google has not implemented a method to prioritize the placement of websites containing this level of useful information near the top of the list. In most cases, the most popular websites contain nothing but junk.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading