Message 1 of 8

Not applicable
08-21-2019
07:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Just going through this and the below line is causing an exception in the tryAnalizeInterference method. I have put a counter and up to 5 objects no issues however beyond 5 it trips with the following exception.. Any idea what might be causing it?
Exception thrown: 'System.Runtime.InteropServices.COMException' in mscorlib.dll DebugPluginLocally2.exe Error: 0 : Processing failed. System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Inventor.AssemblyComponentDefinition.AnalyzeInterference(ObjectCollection Set1, Object Set2) at SamplePlugin1.SampleAutomation.tryAnalizeInterference(Document doc, NameValueMap map)
adoc.ComponentDefinition.AnalyzeInterference(objs);
private void tryAnalizeInterference(Document doc, NameValueMap map=null) { LogTrace("Processing " + doc.FullFileName); try { if (doc.DocumentType != DocumentTypeEnum.kAssemblyDocumentObject) return; var objs = _app.TransientObjects.CreateObjectCollection(); foreach (var item in doc.SelectSet) { if (item is ComponentOccurrence co) objs.Add(co); } var adoc = doc as AssemblyDocument; if (adoc == null) return; if (objs.Count == 0) { var count = 0; foreach (var item in adoc.ComponentDefinition.Occurrences) { if (item is ComponentOccurrence co) { objs.Add(item); LogTrace($"count={count}, {co.Name}"); count++; } if (count > 200) break; } } var interfs = adoc.ComponentDefinition.AnalyzeInterference(objs); if (interfs.Count == 0) return; var hs1 = adoc.HighlightSets.Add(); hs1.Color = _app.TransientObjects.CreateColor(255, 0, 0); var hs2 = adoc.HighlightSets.Add(); hs2.Color = _app.TransientObjects.CreateColor(0, 255, 0); foreach (var interf in interfs) { hs1.Clear(); hs2.Clear(); hs1.AddItem(interf); } } catch (Exception e) { LogError("Processing failed. " + e); } }
Solved! Go to Solution.