Double bounding box
-
Have a snoop around in my plugin that converts the bounding box into edges: http://forums.sketchucation.com/viewtopic.php?t=29377
-
Thanks,but I don't need the real bbox.I just need to retrieve the coordinate of one of the corners of the bbox on the picture.
It should be (-0.707 , 0 , 0) or (0 , -0.707 , 0) . -
So you have the point - but want to move the group so that the point is located at 0,0,0?
<span class="syntaxdefault"><br />tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> point</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vector_to</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ORIGIN </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">!(</span><span class="syntaxdefault"> tr </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span>
-
No,I will explain more:
I have rotated the group for 45 degrees.
If I call the group.bounds.corner(0) ,I get the point of the axis aligned bbox (green circle on the picture).
Instead,I want to have the coordinates of the bbox on the screen ,witch is NOT axis aligned(red circle on the picture).
-
Right - this is where you can look at the plugin I linked to where you can see how I obtain the co-ordinates of the boundingbox.
-
Ok,I have check your plugin and find the line
pts = self.bound_points(bb).map { |pt| pt.transform( entity.transformation ) }
interesting.But I have already try to put the transformation to my point,but the result is wrong:
cube=Sketchup.active_model.selection[0] point=cube.bounds.corner(0) point.transform!(cube.transformation) UI.messagebox point.to_s
The result that I get is wrong (-0,-1.707,0).
As you can see on the picture it should be (-0,-0.707,0).
What em I doing wrong?
-
Ok,I got it.
The mistake was that I was taking the bbox of the group,but should take a bbox of the definition of the group,like in your plugin.
But why didn't you told me to look in your plugin? -
@voljanko said:
I have rotated the group for 45 degrees.
If I call thegroup.bounds.corner(0)
, I get the point of the axis aligned bbox (green circle on the picture).Instead, I want to have the coordinates of the bbox on the screen, which is NOT axis aligned (red circle on the picture).
-
@dan rathbun said:
Yes,it is working,I have test it....BUT,it is only available for groups,not components.
-
@voljanko said:
@dan rathbun said:
Yes,it is working,I have test it....BUT,it is only available for groups,not components.
This is because
.definition()
is exposed toComponentInstance
objects, so:def get_local_bounds(obj) case obj when Sketchup;;Group obj.local_bounds() when Sketchup;;ComponentInstance obj.definition.bounds() else obj.bounds() end end
Advertisement