I am currently developing a viewer extension is which I would like to query different groups of dbIds to have a sort of “contextualized”, more efficient search engine within each model.
On the first version of this extension I’d just directly query the properties of a given array of dbIds on the script itself by calling the model.getBulkProperties()
and model.getBulkProperties2()
methods, however, I soon found out that this approach was likely to cause the main thread of the browser to freeze up for several seconds when dealing with larger models, which means it’s not the right solution for what we’re looking for with this extension.
So after researching a bit more I ran into this APS blog post about userFunctions, as well as this stackoverflow thread showing an example of how to use it, and I was able to implement it into the initial dropdown listing the properties, which reduced the initial load time and freezing considerably, so my question is:
Is there a way to access the model.getBulkProperties()
and model.getBulkProperties2()
methods within a userFunction, or can we only use methods that are defined within the PropertyDatabase class, and in that case, would I have to filter all of the properties manually by querying the attrDef
userFunction parameter or is there another, more efficient way of doing this?
The model.getBulkProperties() and model.getBulkProperties2() methods cannot be used inside the userFunction.
The PropertyDatabase class is available to be used with the userFunction.
In fact, the PropertyDatabase class has the method getObjectProperties() that you use to obtain all properties for a given database id.
You can learn more about the getObjectProperties() method here: https://aps.autodesk.com/en/docs/viewer/v7/reference/globals/Classes/PropertyDatabase/#getobjectproperties-dbid-propfilter-ignorehidden-propignored