July 28, 2017

getBulkProperties method

Default blog image

The .getBulkProperties method return only the specified properties for a list of dbIds, different from .getProperties that return all properties for a single element at a time. The following sample code search for elements with "Steel" on the "Material" attribute, which returns a list of dbIds. Then getBulkProperties query only the "Mass" property on these elements, finally, the for loop sums the values. Note the getBulkProperties requires a list of attributes on the second parameter.

   viewer.model.getBulkProperties(dbIds, ['Mass'],
     var totalMass = 0;
     for(var i=0; i<elements.length; i++){
       totalMass += elements[i].properties[0].displayValue;
}, null, ['Material'])

Simpler than getting a full list of properties with .getProperties in individual callbacks for each dbId.

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