Body Selection in Drawing View from API

Anonymous

Body Selection in Drawing View from API

Anonymous
Not applicable

Hello Autodesk!

 

I am trying to follow the link below to get the body selection in a drawing but I can't convert this to c# code to use in my add-in.

https://forums.autodesk.com/t5/inventor-customization/select-body-in-drawing-view-from-drawing-curve... 

Have a trick to do this?

My main problem is with the ModelGeometry to an occurrence, how this link below.

https://adndevblog.typepad.com/manufacturing/2014/10/expand-browser-and-select-part-by-selecting-edg...

I am use Inventor 2019 API.

 

Thanks!

 

 

0 Likes
Reply
Accepted solutions (1)
484 Views
1 Reply
Reply (1)

Anonymous
Not applicable
Accepted solution

Hello Autodesk!

 

I worked a little harder and found a solution. Below code snippet:

DrawingDocument doc = (DrawingDocument)m_inventorApplication.ActiveDocument;
HighlightSet highlight = doc.CreateHighlightSet();
DrawingView view = (DrawingView)m_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select the view!");
ObjectCollection items = m_inventorApplication.TransientObjects.CreateObjectCollection();

DrawingCurveSegment body = (DrawingCurveSegment)m_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Select the bodies!");
DrawingCurve parent = body.Parent;
try
{
   EdgeProxy oModelprox = (EdgeProxy)parent.ModelGeometry;
   ComponentOccurrence compDef = oModelprox.ContainingOccurrence;
   DrawingCurvesEnumerator oCurveEnum = view.DrawingCurves[compDef];
   foreach (DrawingCurve oCurve in oCurveEnum)
      {
          foreach (DrawingCurveSegment oSegment in oCurve.Segments)
          {
              items.Add(oSegment);
              highlight.AddItem(oSegment);
          }
      }
}
catch (Exception)
{
}

 

I hope it helps!

 

Regards! 

0 Likes