Resetting bounding box to match world axis
-
I recall now, you helped me with this before:
comp.definition.entities.transform_entities(comp.transformation.invert!,comp.definition.entities.to_a)
Didn't know that there might be a difference between bb, and what is shown.
-
@chris fullmer said:
The bounding box that is returned by SU is different than the one that is shown inside of sketchup when you select the component (if I recall correctly).
You need to get the bounds of the definition - then transform that by the instance transformation.
@honoluludesktop said:
comp.definition.entities.transform_entities(comp.transformation.invert!,comp.definition.entities.to_a)
That would reset scaling and translation as well.
@honoluludesktop said:
Didn't know that there might be a difference between bb, and what is shown.
If you get the bounds of an instance the bb will be oriented to the model or world axis.
-
@honoluludesktop said:
The dashed line is the bbox.
The blue lines is the previous bbox?
[attachment=1:lqggpjwr]<!-- ia1 -->Temp00.png<!-- ia1 -->[/attachment:lqggpjwr]
[attachment=0:lqggpjwr]<!-- ia0 -->Temp01.png<!-- ia0 -->[/attachment:lqggpjwr]The dashed lines is the Boundingbox you get when you query the instance for it's boundingbox.
But the blue lines are the actual boundingbox, it's derived from the boundingbox of the definition transformed by the instance transformation. -
The dashed line is the bbox. It's always aligned to the world axis. The blue lines is the bbox when the component is created.
-
I changed the code from
bbox=e.bounds
tobbox=e.definition.bounds
, and got this:
-
Nearly there. Take the points from the boundingbox's corners and transform them by the instance's transformation.
-
OK, before I go there, I aligned the bbox with the world axis and got this:
-
That's because the instance boundingbox will be oriented to the world axis. Whenever the instance is rotated of axis from this you will get a deviance.
I almost forgotten - I got a plugin that draws the selection boundingbox of instances: http://forums.sketchucation.com/viewtopic.php?f=323&t=29377
-
OK done. Where
cl
is a array of clines,entities.transform_entities(e.transformation,cl.to_a)
transforms them into the bbox outline.
Thanks. -
Interesting topic,
This this knowledge end up in a plug-in? I'm looking for a way to reset the bounding boxes of 'rotate multiple' components
Advertisement