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: 

PartsList Export won't accept Options (NameValueMap) Object (.NET addin)

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gavbath
568 Views, 3 Replies

PartsList Export won't accept Options (NameValueMap) Object (.NET addin)

This relates to a .NET addin. Debugging with Visual Studio 2013.

When I try and use a NameValueMap with options in the PartsList.Export method, I get a generic exception:

"Additional information: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"

 

The NameValueMap works fine if I use it in a VBA macro, but fails when using it in a fully compiled .NET addin.

I see that the documentation mentions "Legacy Support" but it works fine in VBA as mentioned above.

 

Here is my C# code:

 

Inventor.NameValueMap exportOptions = invApp.TransientObjects.CreateNameValueMap();
            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(
                new ExeConfigurationFileMap()
                    {
                        ExeConfigFilename = Assembly.GetExecutingAssembly().Location + ".config"
                    }, ConfigurationUserLevel.None);       
     
            exportOptions.Add("Template", config.AppSettings.Settings["Template"]);
            exportOptions.Add("StartingCell", config.AppSettings.Settings["StartingCell"]);
            exportOptions.Add("IncludeTitle", config.AppSettings.Settings["IncludeTitle"]);
            exportOptions.Add("ExportedColumns", config.AppSettings.Settings["ExportedColumns"]);
            exportOptions.Add("TableName", config.AppSettings.Settings["TableName"]);
 
            partsList.Export("T:\\BOM\\TestExport.xls", PartsListFileFormatEnum.kMicrosoftExcel, (Inventor.NameValueMap) exportOptions); 

 

And here are the options:

 

<add key="Template" value="C:\Example\Test.xls" />
<add key="StartingCell" value="A1" />
<add key="IncludeTitle" value="false" />
<add key="ExportedColumns" value="JOBNO;DWGNO;STOCK" />
<add key="TableName" value="Imported Data" />

 

 

Anyone got any idea why this is throwing an exception at the Export call?

Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube


   

Tags (4)
3 REPLIES 3
Message 2 of 4
gavbath
in reply to: gavbath

I think this may actually be related to my configuration file.

I tried with some hard-coded options and it worked.

Will post updates if I figure out what the issue is.

 

Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube


   

Message 3 of 4
gavbath
in reply to: gavbath

While I never figured out what the original issue was caused by, I managed to get everything working by using a settings object instead of a config file.

Not ideal, but achieves the result I was after.

 

Consider this closed.

Gavin Bath
MFG / CAM Technical Specialist
Design and Motion Blog
Facebook | Twitter | LinkedIn | YouTube


   

Message 4 of 4
sethuraman4035
in reply to: gavbath

Hi, I am getting same exeception even with hard coded value.

 

NameValueMap options = m_inventorApplication.TransientObjects.CreateNameValueMap();
//options.Add("Template", @"D:\File Backup\E\Source Codes\Sketch Automation\Sketch Automation\Source Code - June 02\Sketch Automation\RibbonDemoAddin\bin\Debug\BOMTemplate.xls");
//options.Add("StartingCell", "A8");
//options.Add("TableName", "Structured BOM");
//options.Add("IncludeTitle", false);
//options.Add("ExportedColumns", "Description;Material");

BOMView bOMStrucutedView = oBOM.BOMViews["Structured"];
bOMStrucutedView.Export(@"D:\File Backup\E\Source Codes\Sketch Automation\Sketch Automation\Source Code - June 02\Sketch Automation\RibbonDemoAddin\bin\Debug\struc.xls", FileFormatEnum.kMicrosoftExcelFormat, options);

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

Post to forums  

Autodesk Design & Make Report