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

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...