Page 1 of 1

Focus Selected Component in FeatureTree

Posted: Mon Jul 19, 2021 10:34 am
by Kjara
I have an IComponent2 and select it using IComponent2.Select4. I want it to be focused in the bottom pane of the feature tree, meaning that
- if the component cannot be seen due to collapsed ancestor components, those should be expanded.
- if it is out if sight (i.e. too far above/below/right/left of what is currently seen in the window), the feature tree should be scrolled up/down/left/right accordingly, so that it comes into sight.

I tried two things, but none work as expected.

1. IFeatureManager.ExpandFeature:
- It only affects the feature manager top pane, no matter what I put in as the last argument.

2. Traversing feature tree control items (starting with IFeatureManager.GetFeatureTreeRootItem2, going on with ITreeControlItem.GetFirstChild and .GetNext) and setting their Expanded value to true:
- Expanding ancestors works, but they expand more than I want them to: Each component where I set Expanded to true also expands its History folder, its Annotation folder and all its child components.
- It is not guaranteed that the target component comes into sight. It can still be below the visible area due to a small Swx window or low screen resolution.

How do I make Swx focus the selected component?

Attached are an assembly A.SLDASM and a macro where you can see what I just described. Just open A.SLDASM an run the macro (open it with "Edit" so that you can see the debugging window where the macro prints out information).