March 12, 2019

search returns different dbId than selection in UI

You can use the search() function to find elements with certain properties and that might return a different element from the one you imagine.

dbId of elements at different levels

When selecting through the UI, always the leaf elements (the lowest one in the tree branch with no children) are selected. Depending on where the model comes from, those might be Solid/Body elements and not the Component/Part they belong to. It's similar to how things are in manufacturing softwares like Inventor or Fusion 360: there are components/parts and they contain one or more solid bodies with the actual geometry

Elements at different levels of the branch (Component vs Body) have different properties, so depending on what properties you are using for the search, it might not return the leaf element, but one of its parents. In case of the model shown in the topmost picture, only the Component has the "Component Name" property, and only the Body has the "Appearance" property. So if you search for "Component Name", you'll get back a Component and not a Body.
Note: a component may have multiple bodies

However, depending on what you want to do with the element you found, it might make no difference if you found the Component or the Body. E.g. if I use the isolate() function it produces pretty much the same result (apart from a different element being selected in the Structure Browser):

Component vs Body

If you need to, you can of course walk up and down the tree branch to get from a Body to a Component or vice-versa - see enumNodeChildren() and getNodeParentId()

Related Posts

May 10, 2019

Consume AEC Data which are from Model Derivative API

Model Derivative API has been able to extract AEC data of Revit model such as level, grid, views, phase, linked documents etc. And Forge Viewer also provides the corresponding methods ...

Read More

May 9, 2019

Basic point clouds in Forge Viewer

Developers often ask us whether point clouds are supported in Forge Viewer. Unfortunately, the official answer is "no".

Read More

May 6, 2019

Properties shown in case of multiple selection

When selecting multiple objects in the UI then the behaviour of the Property Palette (i.e. which object's properties the palette is showing) can seem a bit random.

Read More