Width, Depth and Length of Component Instance

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.

sas/Ruby/collar%20example.skp
daiku

Posts: 213
Joined: Mon Nov 12, 2007 2:54 pm
Location: Minneapolis
Name: Clark Bremer

Re: Width, Depth and Length of Component Instance

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]

sas/Ruby/collar%20example1.skp
Haggai

Posts: 11
Joined: Tue Mar 25, 2008 12:36 am

Re: Width, Depth and Length of Component Instance

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...
TIG

TIG
Global Moderator

Posts: 13929
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
SketchUp use: architecture

Re: Width, Depth and Length of Component Instance

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.
daiku

Posts: 213
Joined: Mon Nov 12, 2007 2:54 pm
Location: Minneapolis
Name: Clark Bremer

Re: Width, Depth and Length of Component Instance

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==0

you 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

TIG
Global Moderator

Posts: 13929
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 8
SketchUp use: architecture

Re: Width, Depth and Length of Component Instance

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.

sas/Ruby/rafter_example.skp
daiku

Posts: 213
Joined: Mon Nov 12, 2007 2:54 pm
Location: Minneapolis
Name: Clark Bremer

Keyframe Animation plugin - animate your SketchUp model by adding movement to any object.