In the model structure tree, how to obtain the dbid of all leaf nodes under the parent node according to the dbid of the parent node at one level above the leaf node

in the model structure tree, how to obtain the dbid of all leaf nodes under the parent node according to the dbid of the parent node one level above the leaf node

Oct.28,2021

calling L_GetAllChildIdList will get the dbid of all child components (not all parent objects by default). Good luck

let _treeData=viewer.impl.model.getData().instanceTree.nodeAccess;
function _RecursionGetChild (id, list) {
    let length = _treeData.getNumChildren(id);
    if (length < 1) {
        if (list.indexOf(id) == -1) {
            list.push(id);
            // console.log(" >LJason< :--",id,list);
        }

        return;
    }
    // api
    // enumNodeChildrenfindNodeChild 
    _treeData.findNodeChild(id, function (id) {
        // 
        // if(list.indexOf(id)!=-1){
        //     list.push(id);
        // }
        _RecursionGetChild(id, list);
    });
},
function L_GetAllChildIdList () {
    let targets = viewer.getSelection();
    let list = [];
    if (targets) {
        for (let i = 0; i < targets.length; iPP) {
            _RecursionGetChild(targets[i], list);
        }
    } else {
        console.error(" >LJason< :");
        return;
    }
    console.log(" >LJason< :", list);
    return list;
}
Menu