How to Retrieve Forge Viewer objectTree?

前端 未结 2 581
梦毁少年i
梦毁少年i 2021-01-21 16:04

My goal is to highlight a room by adding new geometry to the viewer based on lines I have created in revit like they do here Link

but i can not figure out how to access

2条回答
  •  死守一世寂寞
    2021-01-21 16:51

    Shiya Luo was correct the viewer had not yet finished loading the geometry

    in my extentions Load function I added two event listeners and made sure they both fired before trying to access the instanceTree

     viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
        finishedGEOMETRY_LOADED_EVENT = true;
        if(finishedGEOMETRY_LOADED_EVENT && finishedOBJECT_TREE_CREATED_EVENT ){
            afterModelLoadEvents(viewer);
        }
     });
    viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, function () {
        finishedOBJECT_TREE_CREATED_EVENT = true;
        if(finishedGEOMETRY_LOADED_EVENT && finishedOBJECT_TREE_CREATED_EVENT ){
            afterModelLoadEvents(viewer);           
        }
     });
    

提交回复
热议问题