by honoluludesktop » Thu Dec 16, 2010 4:06 am
Typically, a component's bounding box (bb hereafter) is created parallel to the world axis. When the component is rotated, the bb rotates. When you explode the rotated component, explode it, then recreate the component, the bb is realigned with the world axis.
Is there a way to reset a component's bb to the world axis without exploding, then recreating the component? I tried:
"ComponentDefinition.invalidate_bounds Invalidates the bounding box of your definition. This command forces the update of the bounding box of definition while inside an operation."
But, the bb did not reset parallel to the world axis. Any ideas?
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by Chris Fullmer » Thu Dec 16, 2010 5:26 am
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).
To get the visible bounds to change, you would need to edit the component definition, rotate all geometry inside the definition by the rotation of the instance's transformation (or perhaps the inverse of its transformation??). Then remove all rotation from the instance.
Something along those lines should do the trick,
Chris
-

Chris Fullmer
- SketchUp Team
-
- Posts: 6762
- Joined: Wed Nov 21, 2007 3:21 am
- Location: Davis, CA
- Name: Chris Fullmer
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by honoluludesktop » Thu Dec 16, 2010 8:07 am
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.
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by thomthom » Thu Dec 16, 2010 8:32 am
Chris Fullmer wrote: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 wrote:comp.definition.entities.transform_entities(comp.transformation.invert!,comp.definition.entities.to_a)
That would reset scaling and translation as well. honoluludesktop wrote: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.
-

thomthom
- Global Moderator
-
- Posts: 17915
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by honoluludesktop » Thu Dec 16, 2010 12:28 pm
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. Temp00.png Temp01.png
Please, register (free) to access all the attachments on the forums.
Last edited by honoluludesktop on Thu Dec 16, 2010 12:37 pm, edited 1 time in total.
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by thomthom » Thu Dec 16, 2010 12:34 pm
honoluludesktop wrote:The dashed line is the bbox. The blue lines is the previous bbox? Temp00.png Temp01.png
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.
-

thomthom
- Global Moderator
-
- Posts: 17915
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by honoluludesktop » Thu Dec 16, 2010 12:44 pm
I changed the code from bbox=e.bounds to bbox=e.definition.bounds, and got this: Temp02.png
Please, register (free) to access all the attachments on the forums.
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by thomthom » Thu Dec 16, 2010 12:47 pm
Nearly there. Take the points from the boundingbox's corners and transform them by the instance's transformation.
-

thomthom
- Global Moderator
-
- Posts: 17915
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by honoluludesktop » Thu Dec 16, 2010 12:53 pm
OK, before I go there, I aligned the bbox with the world axis and got this: Temp04.png Temp03.png
Please, register (free) to access all the attachments on the forums.
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by thomthom » Thu Dec 16, 2010 12:56 pm
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: viewtopic.php?f=323&t=29377
-

thomthom
- Global Moderator
-
- Posts: 17915
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2013
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by honoluludesktop » Thu Dec 16, 2010 1:19 pm
OK done. Where cl is a array of clines, entities.transform_entities(e.transformation,cl.to_a) transforms them into the bbox outline. Temp01.png Temp00.png Thanks.
Please, register (free) to access all the attachments on the forums.
-

honoluludesktop
- In Remembrance
-
- Posts: 2219
- Joined: Fri Sep 12, 2008 12:08 am
- Location: Hawaii
by nickdk » Wed May 23, 2012 3:28 pm
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 
-
nickdk
-
- Posts: 98
- Joined: Wed Dec 09, 2009 7:44 pm
by Ad Machine » 5 minutes ago
Not a Premium Member yet? Check out the great time-limited deal we are offering.
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Developers' Forum
|