AddBaseView COM Exception
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've read many articles here about an AddBaseView error and none of them resulted in addressing my issue. I will try to include as much detail I can about what I have tried and what the error is.
First the code, everyone likes code:
String TemplateFilename = m_InventorApp.FileOptions.TemplatesPath + "Standard.idw";
DrawingDocument OutDWGDoc = (DrawingDocument)m_InventorApp.Documents.Open(TemplateFilename, true);
OutDWGDoc.Activate(); // <-- this not usually done just wanted to ensure drawing was active after opening it
MessageBox.Show("Number of Sheets: " + OutDWGDoc.Sheets.Count.ToString()); // <-- this was added to check if sheet count was correct
Sheet OutDWGSheet = OutDWGDoc.Sheets[1]; // <-- in debugger this seems to not set sheet correctly, OutDWGSheet has no object referecable data when stepped over
PartDocument RouterPRTDoc = (PartDocument)m_InventorApp.Documents.Open(FullPartFileName.Replace(".ipt", "R.ipt"), true);
NameValueMap NameValMap = m_InventorApp.TransientObjects.CreateNameValueMap();
NameValMap.Add("SheetMetalFoldedModel", false);
TransientGeometry tgView = m_InventorApp.TransientGeometry;
// The below line is where the COM Exception gets caught
DrawingView DWGBaseView = OutDWGSheet.DrawingViews.AddBaseView((_Document)RouterPRTDoc, tgView.CreatePoint2d(DWGView.Left, DWGView.Top), 1/1, ViewOrientationTypeEnum.kDefaultViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "BaseViewForRouter", DWGView.Camera, NameValMap);
The TemplateFilename does point to a correct path "O:\\NetworkMachine\\SharedFolder\\<extra path info to folder>\\Standard.idw".
m_inventorApp is the inventor application.
See comments in above code for details on things I added to help debug issue and where issue occurs.
Here is the image of the error message returned from Inventor when plugin is executed.
We are using Inventor 2017, Autodesk Desktop App says Inventor 2017 is up to date, Addin is compiled using .NET 4.6.2 Framework, the plugin appears to register with Inventor correctly.
What is strange is this error is happening only on some machines. We checked windows patches and Inventor patches and all are current.
Things we have tried:
- I have attempted Both types of casting methods (ex Obj Blah = (Obj)function.Document...; and Obj Blah = function.Document... As Obj; ) when opening the DrawingDocument and PartDocument.
- This Addin was working without this error until we removed a Style from the Style sheet editor we created and did not need anymore. After the save of the Template we have been getting this error. We are able to open the Template and all looks good, we save the template etc. error still occurs.
- We have tried moving the Template folder to the local C: drive and changed the template path in Inventor, error still occurs.
- I have been compiling the Addin on Windows 10 computer and running Addin on Windows 7 computers. Some work some don't.
- We checked the Styles Editor Application in the start menu for Inventor to ensure the Style we deleted was not in there.
Can anyone help or think of something else we can try to fix this. I am not sure what happened that triggered this issue, it seems strange though it happened with a Style Editor change one would not think it would break this Addin.
Thanks in advance
--
Shannon