0

How do I get the objects I've filtered from the model browse? I've used OBJECT_TREE_CREATED_EVENT, but it's only used the first time when the model is loaded.

Image

1 Answers1

0

You can subscribe to HIDE_EVENT and SHOW_EVENT. You will get the dbid of hidden or showed nodes.

viewer.addEventListener(Autodesk.Viewing.HIDE_EVENT, (nodes, model)=> {   
     
     // nodes returns an object like that :
     // {type: "hide", nodeIdArray: [<dbid>], model: Model, target: GuiViewer3D}

})

viewer.addEventListener(Autodesk.Viewing.SHOW_EVENT, (nodes, model)=> {   
     
     // nodes returns an object like that :
     // {type: "show", nodeIdArray:[<dbid>], model: Model, target: GuiViewer3D}

})

Also, if you want to access the complete list of hidden nodes for a model, you can use viewer.getHiddenNodes(model)

AlexAR
  • 1,052
  • 1
  • 9
  • 15
  • VisibilityManager.js:459 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getHiddenNodes') at s.getHiddenNodes (VisibilityManager.js:459:40) at C.he.getHiddenNodes (Viewer3D.js:2488:44) at forge.viewer.js:84:12 – yudo maryanto Mar 15 '22 at 20:52
  • You probably have a problem with your model reference. Can you try this command `NOP_VIEWER.getHiddenNodes(NOP_VIEWER.model)` ? – AlexAR Mar 16 '22 at 07:45
  • hi alex i got the same error message. Do you have a reference code? this is my reference code https://github.com/Autodesk-Forge/bim360appstore-model.derivative-nodejs-xls.exporter thanks Alex – yudo maryanto Mar 22 '22 at 02:00
  • Try this code I use both functions I described in my answer : [Learn Forge Viewhubmodels NodeJS](https://github.com/AlexPiro/learn.forge.viewhubmodels/tree/nodejs) – AlexAR Mar 22 '22 at 10:32