- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I'm trying to loop through an assembly tree and suppress occurrences, the first occurrence is suppressed but I get the following error right afterwards and no more occurrences are suppressed: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
public void AssemblyCount()
{
AssemblyDocument oAssemblyDoc = (AssemblyDocument)invApp.ActiveDocument;
AssemblyComponentDefinition oCompDef = oAssemblyDoc.ComponentDefinition;
string sMsg = "";
long iLeafNodes = 0;
long iSubAssemblies = 0;
foreach (ComponentOccurrence oCompOcc in oCompDef.Occurrences)
{
if (oCompOcc.SubOccurrences.Count == 0)
{
oCompOcc.Suppress();
iLeafNodes++;
}
else
{
oCompOcc.Suppress();
iSubAssemblies++;
processAllSubOcc(oCompOcc, ref sMsg, ref iLeafNodes, ref iSubAssemblies);
}
}
}
private void processAllSubOcc(ComponentOccurrence oCompOcc, ref string sMsg, ref long iLeafNodes, ref long iSubAssemblies)
{
foreach (ComponentOccurrence oSubCompOcc in oCompOcc.SubOccurrences)
{
if (oSubCompOcc.SubOccurrences.Count == 0)
{
oSubCompOcc.Suppress();
iLeafNodes++;
}
else
{
oSubCompOcc.Suppress();
sMsg = sMsg + oSubCompOcc.Name;
iSubAssemblies++;
processAllSubOcc(oSubCompOcc, ref sMsg, ref iLeafNodes, ref iSubAssemblies);
}
}
}
Solved! Go to Solution.