getBulkProperties method

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.search('Steel', 
function(dbIds){
   viewer.model.getBulkProperties(dbIds, ['Mass'],
   function(elements){
     var totalMass = 0;
     for(var i=0; i<elements.length; i++){
       totalMass += elements[i].properties[0].displayValue;
     }
     console.log(totalMass);
   })
}, null, ['Material'])

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

Posts by author

Augusto Goncalves
Developer Advocate, Autodesk

Developer Advocate at Autodesk since 2008, working with both desktop and web/cloud apps using top technologies, like C#, JavaScript, NodeJS and any other that can solve problems and improve workflo