Width, Depth and Length of Component Instance
-
I need to determine the width, depth, and length of a rectangular solid. Of course, one would just use the bounding box, and this works for me in some instances, but in others, there are sub components that are contained within the parent, but are set at an angle relative to the parent, and whose bounding box thus protrudes outside the rectangular bounds I'm really looking for. See the example. I think the solution is to make a copy, explode it all, then place all the pieces back together as one group, then take it's bounding box, then delete it. Anyone think that will work? Is there a way to put all the pieces into a group? CB.
http://www.sketchucation.com/forums/scf/sas/Ruby/collar%20example.skp
-
hello,
If I understood you right here is what I did to your timber.
Edit the timber component, and then select this tenon edit cut then paste it outside the Timber componentexplode it and make component again, the bounding box will be on the axis, then replace it inside the Timber component, don't forget the other side.[Haggai]
http://www.sketchucation.com/forums/scf/sas/Ruby/collar%20example1.skp
-
If it's a solid faced rectangule then get the bounds of two (or three) of the 3D opposed faces... then you can work out the xyz dims of the object, without resort to it's over all bounds...
-
Haggai:
That's great - that's just what I want. I see how you did that with your mouse, but how do I do it from within a ruby script?
TIG:
It's not really a rectangular solid. In the shop, I cut it from a rectangular solid (a really big piece of timber). I'm working on a ruby to give me the materials list. I need to know what size timber I need to cut something like this. So there may be more faces than just the 6 standard faces of the rectangular solid. I won't know in advance how many, or which face is which.
Thanks for your help guys. CB.
-
Even if it's not rectangular you can still find horizontal and vertical faces of an enclosing rectangle for its main faces.
horizontal>>> face.normal.z==-1 >>>down ...==1 >>>up
vertical>>> face.normal.z==0you can find the bottom down face (faceh), find its edges, then find an edge that matches in the se of vertical faces' edge (if you might have say several vertical faces then find the one with the longer edges if that's the one you need etc...)
you now have a long bottom face (faceh) and an adjoining vertical face (facev) that's sharing a (long) edge.
faceh.bounds.max.x-faceh.bounds.min.x and similarly for .y give the plan size (x & y) and facev.bounds.max.z-facev.bounds.min.z give the overall height (z) ?
-
TIG:
Unfortunately, that won't work for all cases. Here's another example.
The result I want in this case is 10" x 10" x about 11'. But this one does not have a "horizontal" face. The "bottom" face has bounds of ~7' x ~7'. I know how to "lay it down". But I think the next step is to recursively explode it, and then un-explode it again and take the bounds of the new object. But I have no idea how to un-explode.This all works perfectly if I do it manually, but how to do it from ruby?
Seems like I've been here before... CB.
http://www.sketchucation.com/forums/scf/sas/Ruby/rafter_example.skp
Advertisement