Search code examples
autodesk-viewerautodeskautodesk-model-derivative

How to get dbId of visible objects in model viewer?


I already tried this two answers: How to get dbId of only visible objects in Viewer? and APS / Forge Viewer get only un hidden geometry dbid but nothing worked. The first answer code gives me a list of all objects dbIds in model, not all visible, and the second seems to complement de first one, but the function viewer.getHiddenNodes() doesn't work like it should, example:

example

Only walls are visible and:

example2

How do I get only the visible objects dbIds?


Solution

  • The Model Structure panel calls viewer.isolate( dbIds ) when clicking on the tree node. So, please use viewer.getIsolatedNodes() instead.

    if you just get few dbIds inside, then it means you clicked on the supper node on the tree (e.g. Walls). Then you can get children node dbIds following https://aps.autodesk.com/blog/enumerating-leaf-nodes-viewer