PropertyDatabase
new PropertyDatabase(dbjsons)
The Property Database contains property information for each part of a model. The data is read-only, since it has been packed to optimize memory footprint. It’s implemented as an Entity-Atribute-Value (EAV) set of tables. LMV keeps the PropertyDatabase in a browser worker thread to prevent compute-intensive methods to block the main browser UI thread. Words “Attribute” and “Property” are use interchangeably.
Parameters
dbjsons* |
Properties
enumObjectProperties | Iterates over all properties for a given database id and invokes the supplied callback function. |
getPropertiesSubsetWithInheritance | Given an object ID, returns the corresponding value IDs for the given list of attribute Ids. Takes into account instance_of inheritance of properties. |
Methods
getObjectCount()
Obtains the number of database ids (dbIds) available. These ids range betwee 1 (inclusive) up to getObjectCount() (exclusive).
Returns
type | description |
---|---|
number |
getAttrValue(attrId, valId, integerHint)
Obtains the actual value of a property.
Parameters
attrId* number | The attribute id |
valId* number | The value id |
integerHint boolean | If true the return value will be casted to integer. |
Returns
type | description |
---|---|
getExternalIdMapping(extIdFilter)
Obtains a map between each database id (dbId) and their corresponding external-id. The external-id is the identifier used by the source file. Example: A translated Revit file has a wall with dbId=1, but in Revit (desktop application) the identifier of that wall is “Wall-06-some-guid-here”.
Parameters
extIdFilter Array.<number> | Limits the result to only contain the ids in this array. |
Returns
type | description |
---|---|
object | map from dbId into external-id. |
getSearchTerms(searchText)
Given a text string, returns an array of individual words separated by white spaces. Will preserve white spacing within double quotes.
Parameters
searchText* string | Text to search |
bruteForceFind(propertyName)
Given a property name, it returns an array of ids that contain it.
Parameters
propertyName* string | Property name |
getLayerToNodeIdMapping()
Specialized function that returns: { ‘layer-name-1’: [id1, id2, …, idN], ‘layer-name-2’: [idX, idY, …, idZ], … }
getAttributeDef(attrId)
Unpacks an attribute value into all available components.
Parameters
attrId* number | The attribute id. |
Returns
type | description |
---|---|
object | containing name , category , dataType , dataTypeContext , description , displayName and flags . |
enumAttributes(cb)
Invokes a callback function for each attribute-id in the model.
Parameters
cb* function | Callback invoked |
Examples
pdb.enumAttributes(function(attrId, attrDef) {
// attrDef is an object
if (attrDef.name === 'name') {
return true; // return true to stop iteration.
}
})
findLayers()
Iterates over the property database and finds all layers.
Returns
type | description |
---|---|
object |
enumObjects(cb, fromId, toId)
Iterates over all database ids and invokes a callback function.
Parameters
cb* function | callback function. Receives a single parameter: the database-id. Have the function return true to abort iteration. |
fromId* number | starting id (inclusive) |
toId* number | end id (exclusive) |
_ignoreAttribute(propertyFilter, attrId)
Checks whether an attribute must be excluded from Diff comparison.
Parameters
propertyFilter* Object | A key-value pair of category and property names to ignore from Diff |
attrId* number | The attribute id. |
numberOfAttributes()
Returns count of the number of attributes
Returns
type | description |
---|---|
number |
numberOfValues()
Returns count of the number of values
Returns
type | description |
---|---|
number |