Align axes with a face and reset axes

Very few companies have their bug tracker online publicly - the ones that do usually still have a private one as there is often internal chatter not suited for public.

I do appreciate your help tt, so there may be a workaround that doesn’t involve too much hairy matrix multiplication.
Here’s the situation in more detail:
User has already created a face in 3D space. He has placed on the face a number of objects (groups and/or components). They might be windows, or furniture or skylights. They might be nested several levels and rotated arbitrarily Objective is to equally space these objects across the local X or Y extent of the face.
My method was to align axes with the face. Then group each object individually with a new cpoint at its center: this just to give me a new bounds oriented with the face. Then sort objects by local x or y, then move objects so they are equally spaced (either center to center or space between), then explode each object (deleting cpoint) to get back to original objects. Then reset axes.
Any advice?

Maybe Dan, you can post the list of things you know are unexposed on the FR forum?

That’s very UI centric way to do it. Often one do things differently with the API. For example, using the UI one create geometry first - then group it. Using the API one create the group first and add geometry directly to the group.
Sounds to me like setting the axes in this case is something similar.

Can you perhaps provide a few screenshots of opening scenario and end result? Some visuals would make this easier to fully understand and provide a better solution.

All the geometry exists in advance. The grouping I’m doing only to get a bounds aligned to the face. Then I explode after I move the objects. Screenshots will have to wait til tomorrow.

I see only 4 posts in the API FR forum. Did you or soimeone post this item somewhere when first discovered?

OK tt_su here is a screen shot showing the general case before and after:
Before: 6 objects on a plane (although they don’t have to be on the plane).
After: the 6 objects distributed across the plane x extent with equal spacing in between.

I see. There should not be any need to change axes create temporary groups only to explode them for this.

I assume you have found the orientation of the face - and it’s always a rectangle?

You can create a transformation representing one of the corners of the face from the origin. Then use the inverse of that to calculate the local distribution of your objects. Once you have the local transformation for them you multiply that with the first “face-transformation”.

I need to add:
No it’s not always a rectangle, I intend to use the bounds of the face to define local x extent.
The 6 objects may be arbitrarily nested, rotated and scaled about multiple axes.

I’m sure all this is doable using 3D transforms, but my strategy of setting axes and grouping etc was entirely about making the code much easier to write.
At this point I need to confess that my aging brain was hoping to avoid relearning 3D transforms which I last contemplated (painfully) over 20 years ago.

The API says “geometrical transformations in 3 dimensions which is covered extensively on the Internet.” Could you point me to a good 3D transforms for dummies?

Start on Wikipedia: Transformation - Wikipedia

but …

from Sketchup::BoundingBox :

Bounding boxes are three-dimensional boxes (eight corners), aligned with the global axes, that surround entities within your model.

1 Like

Are you sure that’s right? I assumed the bounding box is the blue box you see when you select a group. If the group has been rotated the box does not align with the global axes.

Really? I quoted the API documentation, and your making an assumption.

:spank: :spank: :ninny: :nanny: :poo: :poo:

:laughing:

Seriously,… the object hilighting and bounding boxes are two different things.

You taught me always to question what the API says.
Anyhow, it’s easy to test when I get back from my bike ride.

I know, just teasing.

I also tested it to be sure they hadn’t changed things when I wasn’t looking.

Yes, the Geom::BoundingBox class does not represent the selection bounds in the viewport. If you want to obtain the 3d points for that you can look at this extension I wrote that draws edges and faces matching the viewport bounding boxes: https://bitbucket.org/thomthom/draw-boundingbox/src

My tests show that you are right (again).
Also changing the axes has no effect on the bounding box coordinates. It’s always based on global coordinates. So bounding box is not as useful as I hoped.

Incidentally, this is another unfortunate case where the normal User UI terminology (see Preferences… Compatibility) clashes with API terminology.
Seems that whoever developed the API wasn’t a user, or maybe UI terminology changed (eg: Page vs Scene) changed.

Yea, the API class names matched in the old days, then the UI names diverged.
They could have created aliases for the new names, but decided it would clutter the docs.
ie

Sketchup::Scene = Sketchup::Page

is_a? (or kind_of?) and === seems to work as expected for the aliases.

1 Like

TT:
I’m working my way through thomthom/draw-boundingbox.
Also found source for TT_lib2 which is called twice.
Question: Is the logic in TT instance.rb still necessary? or are the bugs fixed?
I’m using licensing so I only need to support 15.0 and later.