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
Solved! Go to Solution.
Solved by gavbath. Go to Solution.
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
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
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);