Get selected occurrence without interaction

Get selected occurrence without interaction

Anonymous
Not applicable
850 Views
4 Replies
Message 1 of 5

Get selected occurrence without interaction

Anonymous
Not applicable

Hi,

in a separate window I want to show some properties and information of an selected occurrence in an assembly. How can I get the selected occurence from browser or graphical window?

Is there an event that gives me the selected object? I know that there are SelectEvents from Interaction, but I'd like to do this without interaction because I want to run my window in the background. I think that Interaction is not the right way because it means an active selection for a specific command, but not to capture something from the background.

 

I have in mind to do this with with a timer that looks for the selected object, but I'm not sure if this is a working solution and would prefer working with some kind of event. Is there something I can use?

 

Thanks

Andreas

0 Likes
Accepted solutions (1)
851 Views
4 Replies
Replies (4)
Message 2 of 5

Balaji_Ram
Alumni
Alumni

Hi Andreas,

 

The selected browser node can be identified using the following code snippet 

 

BrowserPane oPane = assyDoc.BrowserPanes["Model"];
            BrowserNode oTopNode = oPane.TopNode;
            foreach (BrowserNode node in oTopNode.BrowserNodes)
            {
                if (node.Selected)
                {
                    MessageBox.Show(String.Format("Selected browser node : {0}", node.BrowserNodeDefinition.Label));
                }
            }

For an event, please try using the BrowserPanesEvents. 

You can get hold of it using the Document.BrowserPanes.BrowserPanesEvents.OnBrowserNodeActivate.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi Balaji,

 

thanks for your support. I got the example running and capture the selection with a timer although I would prefer an event.

Unfortunately I don't get the BrowserPaneEvents with the EventWatcher. Whatever I click it seems that the OnBrowserNodeActivate event is not fired.

 

Regards,

Andreas

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni
Accepted solution

You don't need to go through the browser but instead can use the Document.SelectSet property.  This returns a SelectSet object which will contain whatever is currently selected in the document.  There is also an OnChangeSelectSet event that is fired whenever the contents of the selection changes.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Brian,

 

thanks a lot for your assistance. I checked the DocumentEvents.OnChangeSelectSet-Event and this is obviously exactly what I was looking for. Really crazy that I dindn't see the wood for the trees.

 

Regards,

Andreas

0 Likes