Bi SAl MhRzn
Bi SAl MhRzn

Reputation: 71

Get element Ids of isolated or cut-section objects in autodesk forge

I am trying to show the list of elements name and properties that are isolated in a model, or the elements that are shown in a section that is cut in the model. Is there any way to get the element ids of a model ,whose section is cut or the elements that are isolated.

Upvotes: 1

Views: 1039

Answers (1)

michael beale
michael beale

Reputation: 1196

To retrieve the isolated IDs, use this:

> NOP_VIEWER.getIsolatedNodes()
[8, 14, 38, 47]

which will return an array of IDs, as per the diagram.

isolatedShaver.jpg

To retrieve the property of ID 14, use this:

> NOP_VIEWER.model.getProperties( 14, i=>console.log(i)) 
{dbId: 14, properties: Array(2), externalId: "xobxtGd+JEWr+mJcpKnNyg", name: "NOR-P-001:1" ...etc}

You can find all of the attributes in this object returned, specifically, check the 'properties' array.

Besides Isolated state, there is also, hidden and selected state, which you can retrieve from the view state, like this:

> NOP_VIEWER.getState().objectSet[0]
{id: [14], isolated: [8, 14, 38, 47], hidden: [], explodeScale: 0.21, idType: "lmv"}

Notice that id 14 (green arrow) is both isolated and selected.

To retrieve the list of IDs hidden due to a section box, you would need to find all objects within the section box AABB and subtract that list from the entire model list. Please refer to this great blog post, by Philippe Leefsma, on how to find objects within a bounding box: https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-part-ii

If you are sectioning in one plane, then you could dramatically simplify the code, but the concept is the same.

Hope that helps.

Upvotes: 1

Related Questions