FaceMe Components have extra large BoundingBox?
-
I am trying to work with the bounding boxes of components and I am finding that faceme components bounding boxes are not working as expected. So I wrote a little snipet of code that adds a c_point to all the corners of a bounding box. And sure enough, the face_me components bbox is extra-large. I figure it might have something to do with the fact that they can swivel, but that sort of does not seem logical. The large bbox does not really correspond to the size of the component or its axis or anything. So is this just a bug? or is it working as exected for reasons I'm thinking of? Here's the script exactly as I run it from the webconsole. Select a group and then run the code.
model = Sketchup.active_model ents = model.entities sel = model.selection bbox = sel[0].bounds p1 = bbox.corner 0 p2 = bbox.corner 1 p3 = bbox.corner 2 p4 = bbox.corner 3 p5 = bbox.corner 4 p6 = bbox.corner 5 p7 = bbox.corner 6 p8 = bbox.corner 7 ents.add_cpoint p1 ents.add_cpoint p2 ents.add_cpoint p3 ents.add_cpoint p4 ents.add_cpoint p5 ents.add_cpoint p6 ents.add_cpoint p7 ents.add_cpoint p8
Any thoughts on this?
Chris
-
Chris,
(probably not understanding your question, but) when I import a file that has a component created as a face-me (rather than loose geometry with the file itself set as face-me) I get (why?) an extra large bounding box: so I expode the import and get the face-me with its normal sized bounding box...?
Best, Tom. -
Wierd. Here's a map/model of the corners of a boundingbox for the faceme cube component in the model as the view is rotated.
When the axis is moved to the middle of the compo, the corners move like this:
-
I'm going to guess that its related. I just don't know if its a bug or not. I think it probably is.....? In ruby there is a way to create bounding boxes that are not necessarily displayed. That is the bounding box I am having issues with - the one I can create in ruby. But I bet that somehow SU is confused somewhere.
I have managed to go into the component and get all the points I need. But its a bit of a tedious workaround. And I'm still not done with it, so I might run into more issues down the road...
Chris
-
Here's the webconsole code to make the pattern.
model = Sketchup.active_model $entities = model.entities $selection = model.selection class MyViewObserver < Sketchup;;ViewObserver def onViewChanged(view) pts = ((0..7).map{|n| $selection[0].bounds.corner(n)}) pts.each {|pt| $entities.add_cpoint(pt)} end end # Attach the observer. Sketchup.active_model.active_view.add_observer(MyViewObserver.new)
-
Very cool Jim, thanks for the code to play with. That is quite interesting. I choose its a bug.
Chris
-
The bounds method gives you an AABB not an OBB, so it is expected behavior that it will be 'fat' when your object is rotated to be not aligned with the XYZ axes.
ie There is a difference between taking the BB in local space and transforming those (8) points into world space compared to transforming the object into world space and determining the BB (which is what SU does).
Move along..
Adam
-
@adamb said:
The bounds method gives you an AABB not an OBB, so it is expected behavior that it will be 'fat' when your object is rotated to be not aligned with the XYZ axes.
I'm not sure what you mean by AA and O.
One of oddities in the images is that the points are a little more than "fat" - they are too big for being just the result of a bounding box created around rotated geometry. Another weird thing is that the points are above and below the compo in the Z direction.
-
Mea culpa
AABB = Axis aligned Bounding box (blue box)
OBB = Oriented Bounding box (red box)
Advertisement