The objects received from TopSolid are not always loaded in the same order, which is problematic to rebuild the tree.
On the link, try to reload the page multiple times and you will see that the Ensembles tree order changes. Or look at the order in the console
I don’t think I fully understand the situation, but regardless in which orders objects come in, the viewer will always respect the original hierarchy when building it’s tree. If you need a particular structure/hierarchy, you will have to create one at host-app level.
But maybe if you explain why the order of the object is important for your particular use case perhaps we could assist in less obvious ways
Why order is important to us:
In TopSolid, there is an important BIM concept called sets. An entity (point, axis, sketch, etc.) can belong to one set, no set or several sets. Sets can also contain sub-sets, sub-sub-sets and so on. They form a tree in TopSolid that we want to reproduce in the viewer. @ahmedwael94 sent me these sets (the top-level ones) from TopSolid at the same level as the entities, with an isSet property so that I could find them in the world tree. They don’t contain the entities directly, but references to the entities. (so that if a sketch belongs to several sets, you only send it once).
Then I rebuild everything from the children of these sets.
The viewer does respect the original hierarchy, however it does not enforce any specific order of sibling nodes. As the viewer gets fed objects by the object-loader, it adds them to the tree, indeed respecting their hierarchy, but in no predefined order. Maybe closures respect the original order @dimitrie ?
If closures are also a no go, I believe you might need to enforce order with custom data. You already have an isSet custom property, so you could also add an ordered list of children ids for each set, or anything that can help enforce order.
Thanks @alex
Indeed, we’re looking for a workaround directly in the Speckle.TopSolid connector.
I also wanted to understand the problem a bit more, thank you for your explanations.