Get:Properties Selection Component. Autodesk Forge

Viewed 13

I am trying to generate a list of elements (dbIDs) of a navisworks model that comes from revit and istram IFC files. I have a problem in the selection tree levels since I need the first elements of each object and for revit files I select the body. How can I build this code so that it reads me the components of a higher level? If someone can help me, I would really appreciate it

    constructor(viewer) {
        this._modelData = {};
        this._viewer = viewer;
    }

    init(callback) {
        var _this = this;

        _this.getAllLeafComponents(function (dbIds) {


            console.log(dbIds);

            var count = dbIds.length;

            dbIds.forEach(function (dbId) {
                viewer.getProperties(dbId, function (props) {
                    props.properties.forEach(function (prop) {
                        if (!isNaN(prop.displayValue)) return; // let's not categorize properties that store numbers
                        
                        // some adjustments for revit:
                        prop.displayValue = prop.displayValue.replace('Revit ', ''); // remove this Revit prefix
                        if (prop.displayValue.indexOf('<') == 0) return; // skip categories that start with <

                        // ok, now let's organize the data into this hash table
                        if (_this._modelData[prop.displayName] == null) _this._modelData[prop.displayName] = {};
                        if (_this._modelData[prop.displayName][prop.displayValue] == null) _this._modelData[prop.displayName][prop.displayValue] = [];
                        _this._modelData[prop.displayName][prop.displayValue].push(dbId);
                    })
                    if ((--count) === 1) callback();
                });
            })
       });
            

   

0 Answers
Related