Inventor API: How to get the Document of a component selected in the Drawing Model Tree using SelectSet?

Inventor API: How to get the Document of a component selected in the Drawing Model Tree using SelectSet?

mfantone
Participant Participant
229 Views
2 Replies
Message 1 of 3

Inventor API: How to get the Document of a component selected in the Drawing Model Tree using SelectSet?

mfantone
Participant
Participant

I’m working with the Inventor SelectSet API in a DrawingDocument and I need to retrieve the Document object of a component selected from the Model Tree (browser).

 

However, whenever I select a component node in the browser, the item returned from SelectSet is of type GenericObject. This object type does not expose any useful information about the underlying component or its referenced document.

 

Any guidance or examples would be greatly appreciated.

 

selectset_1.png

 

selectset_2.png

0 Likes
Accepted solutions (1)
230 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @mfantone.  Are you just exploring around, or is there a specific reason you are attempting to get that exact object through pre-selection?  If you just need to select it for some reason, but it does not necessarily need to be done through the model browser tree, or through pre-selection, then there are likely other ways to get to it by code.  Not much we can do about it only returning a GenericObject in that exact situation.  If your code knew which Sheet, and which View, (such as by index or names) you could attempt to navigate the model browser tree from a higher level to get to it.  We can pre-select the DrawingView by its model browser node, and be able to recognize it in the SelectSet, but usually not much at lower levels.  Since the same model object node can potentially be found under multiple views, getting the right browser node can be tricky when navigating for it, especially when some of the views are 'projected', which makes them child nodes of their parent view's node, and such situations.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

mfantone
Participant
Participant
Accepted solution

Hi @WCrihfield, thanks for the quick response! I initially considered traversing the model browser tree to retrieve the selected model object, but that approach could become problematic with larger models. Fortunately, I found that we can obtain the document of the selected model directly through the API using DrawingDocument.ProcessViewSelection, which simplifies things quite a bit.