Retrieve Element from externalId Autodesk Forge

Asked 1 year ago
Viewed 363 times

I have a external Id and i want to retrieve element of it to set theming color but i can't search method to do this. I tested, but it's not run.


viewer.getElementById() is right ? I search in document of forge but get no result. Seem document of forge is difficult than document of revit api. Many thanks !

asked 1 year ago

Correct Answer

I am not sure if getElementById() exist in Forge or where it is documented.

If you would like to set colors of an object in your model, you need to use dbId instead of externalId. Fortunately, there is a really nice function to get dbId from externalId which is called getExternalIdMapping().

You can find it here in the documentation:

Returns an object with key values being dbNodeIds and values externalIds. 
Useful to map LMV node ids to Fusion node ids.

Example usage could be:

viewer.model.getExternalIdMapping(data => console.log(data))

With this you can retrieve dbId to set its color.

answered 1 year ago