Hello,
I have a function that return an array of edges of an selected part on an assembly document
Component2 comp = (Component2)uA.swSelMgr.GetSelectedObject6(1, -1);
double len = 0;
if (comp != null)
{
Body2 SwBody = (Body2)comp.GetBody();
int n = SwBody.GetEdgeCount();
Array AllEdges = (Array)SwBody.GetEdges();
for (int i = 0; i < n; i++)
{
Edge e = AllEdges.GetValue(i) as Edge;
...
}
}
Now I need it to work on a part document, but the comp.GetBody() always returns null.
I tried to differentiate the two components:
if (swModel.GetType() == (int)SolidWorks.Interop.swconst.swDocumentTypes_e.swDocASSEMBLY)
comp = (Component2)uA.swSelMgr.GetSelectedObject6(1, -1);
else if (swModel.GetType() == (int)SolidWorks.Interop.swconst.swDocumentTypes_e.swDocPART)
comp = swRootComp;
But I got the same problem.
Is there any other way to get the edges of the part?
Thank you.
SolidworksApi macros