2

For BIM model quantity take off I need to filter on all elements that are relevant for quantity take off. Below are some visual examples of the element I need (green circled) and which elements I don't need (red cross)

Example 1 enter image description here

Example 2 enter image description here

How can I filter only on elements in the Autodesk Forge API that are relevant for quantity take off?

When I use the API I get all levels and I didn't manage to get the level I need.

Roderik
  • 31
  • 2

1 Answers1

0

First of all, you'll need to define the logic to filter these elements.

From the images you've shared, the hierarchy tree of your model seems to be organized in a way that you're interested in the nodes in the 5th level from the root node. So, if that's the case, you could use something like the snippet below to find the nodes' paths and then filter it to retrieve the 5th-level nodes' dbids:

 var findfifthNodes = function (model) {
    return new Promise(function (resolve, reject) {
        model.getObjectTree(function (tree) {
            let nodes = {};
            tree.enumNodeChildren(tree.getRootId(), function (dbid) {
                let nodepath = [dbid];
                if(!!nodes[tree.getNodeParentId(dbid)]){
                    nodepath = nodepath.concat(nodes[tree.getNodeParentId(dbid)]);
                }
                nodes[dbid] = nodepath;
            }, true /* recursively enumerate children's children as well */);
            let fifthNodes = Object.values(nodes).filter(p => p.length == 5).map(a => a[0]);
            resolve(fifthNodes);
        }, reject);
    });
}

You can also add your own custom tree view that might be more suitable to your workflow.

To achieve that, please refer to https://aps.autodesk.com/blog/custom-tree-views

João Martins
  • 388
  • 3
  • 10