12 May 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 Article