Search code examples
autodesk-forgeautodesk-viewerautodesk-model-derivative

Forge Viewer Properties Drop Down


I'm trying to create a dropdown menu that is populated by a distinct list of all the property names in a model/multiple models that are in the forge viewer.

is the best way to

1 . get bulk properties 2. filter to just get the name of the properties 3. create a unique array o values from that

or is there a simpler way of doing this ? it seems like there should be


Solution

  • A more efficient way would be to use the executeUserFunction to run a custom piece of code in the property database web worker, and collect all property names from there, e.g., like this:

    async function getPropertyNames(model) {
        function userFunction(pdb) {
            let propertyNames = [];
            pdb.enumAttributes(function (attrId, attrDef) {
                propertyNames.push(attrDef.name);
            });
            return propertyNames;
        }
        return await model.getPropertyDb().executeUserFunction(userFunction);
    }