July 28, 2017

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