Down to Top traversal
-
Hello everybody,
I've got a little problem in sketchup.
I'm parsing all the elements from my Model, using the entities method, to go from the model, to the group, to the face, to the position....It's for me a top-down traversal so I can get all the transformations of my elements. This works great.But now, I need to do the reverse, I've got an entity, and I want to get all his parent's group transformation, but when I use the parent method on a Face for example, it takes me to a DefinitionList, which is directly in the model, I can't get the parent group and his transformation. Sometimes, it works using the instances method on the DefinitionList to get the group that uses this definition, but if many groups shares the same definition, I don't know which one is the selected one.
If somebody can help me, it would be great
thanks in advance and sorry for my bad english :s
-
The problem is that given an entity inside a group or component, you have no idea of which instance it belongs to.
Though, if you assume, or make a requirement, that there is only one instance, then it is possible.But can I first ask why and what you are trying to do?
And how are you getting this entity to begin with? -
In fact, I'd like to add a physical engine created by our society to sketchup, like sketchy physics does.
So each entity in sketchup is linked to a body in my engine. I have the list of the linked entity in my own array so I can access them through this array.When I make my simulation, to initialize value, I have to get the whole transformation of my entities to set their position in the physical world, and then at each step I get the transformation in my engine and have to set it to sketchup entity, but if they are in a group (for example a group bike, we'd like to turn the wheels) I have to extract the wheel transformation of the bike transformation, as the wheel's transformation depends on the bike's transformation.
-
So in your array of entities, yo might have edges/faces? How did you get that entity in the first place?
-
In my array I have groups, that I get from a top to down traversal. I think the best solution will be to store my own couple (transformation,group) in my own tree structure to do the thing I need.
-
Yea - you'd need to keep store the path to where you found the group in the first place.
Advertisement