May 12, 2018

Get "Configuration Specific" properties of SolidWorks files

SolidWorks files have Configuration Specific data as well - see above picture. When looking at such a model in the Viewer you might be interested in finding out the properties related to the Active Configuration of the model. 

The Properties palette in the Viewer does not list those properties currently, but they are extracted from the original model and using the Viewer API you can get to them like this

function getActiveConfigurationProperties (viewer) {
    var dbIds = viewer.getSelection();

    if (dbIds.length !== 1) {
        alert("Select a single item first!");
        return;
    }

    viewer.getProperties(dbIds[0], (props) => {
        props.properties.forEach(prop => {
            if (prop.displayName === "Active Configuration") {
                viewer.getProperties(prop.displayValue, confProps => {
                    console.log(confProps);        
                });  

                return;
            }
        })
    })
}

Just select in the Viewer the object whose Active Configuration property you need and run the above code:

Properties shown in console

PS: Make sure you select the actual component and not the body - which is what the Viewer selects by default when you click on an object:

Selection in Viewer

Related Posts

July 11, 2019

New Autodesk Forge Viewer 7.0 is Now Available

Autodesk Forge is our collection of Application Program Interfaces (APIs), documentation, sample code, and a community of cust

Read More

July 10, 2019

Look for exact property value and more

When using the search() function of the Viewer, you can only look for strings that at least partially match a given value.

Read More

July 9, 2019

Webpack and three.js in forge applications

In the newer versions of forge viewers( v6 and above) three.js is included in the forge viwer js file itself.

Read More