AnsweredAssumed Answered

Can't seem to get selected component in a drawing

Question asked by Eric Snyder on Apr 22, 2020
Latest reply on Apr 22, 2020 by Josh Brady

My feature tree in a drawing looks like this:

I want to get the selected component "Assem1". I am selecting "Assem1" as pictured above and then run my code:

IModelDoc2 model = (IModelDoc2)App.ActiveDoc;
SelectionMgr sm = (SelectionMgr)model.SelectionManager;
IDrawingComponent selectedComponent = (IDrawingComponent)sm.GetSelectedObjectsComponent4(-1, -1);
int count = sm.GetSelectedObjectCount2(-1);

I am getting a count of zero no matter what I try. In fact, after my simple script runs my selection is unhighlighted.

What might be happening? How do I get the currently highlighted IDrawingComponent?