sergeyz
sergeyz

Reputation: 1337

What Autodesk Forge event to listen to to know when can call viewer.hideAll and viewer.show methods

I call viewer.hideAll and then viewer.show to implement custom filtering functionality in Forge Viewer. If I have a list of dbids for certain elements and I call two methods mentioned above as soon as viewer gets initialized, then nothing happens. I mean no elements get hidden or shown and no error gets thrown from the Forge viewer instance.

Based on information that I have right now, I can subscribe to Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT event to know when to call above methods, but it takes at least 20 seconds (for 200mb model) and sometimes even takes 60 seconds (for 1gb model) to fire that event. Is there some other event that fires earlier than Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT that I can use to know when to call viewer.hideAll and viewer.show methods?

Also, if someone knows and shares a better way to implement filtering functionality in the Forge viewer, that would be greatly appreciated.

Upvotes: 0

Views: 150

Answers (1)

Eason Kang
Eason Kang

Reputation: 7115

Both viewer.hideAll and viewer.show methods control the node visibilities, so you must wait for the geometries to be loaded (i.e. when Autodesk.Viewing.GEOMETRY_LOADED_EVENT gets fired. )

viewer.addEventListener(
    Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
    (event) => {
       // viewer.hideAll
       // viewer.show
    });

Upvotes: 1

Related Questions