Align axes with a face and reset axes

If I select a face I can right click and click “align axes”.
Later I can right click on an axis and click “reset”.
But how can I do these 2 things in ruby?

I see the Transformation.axes method but where is the global axes object to apply it to?

1 Like

The global axes and a class for user co-ordinate system (UCS) instances, have not yet been exposed in the API.

They been long requested. Add your voice by posting this in the FR forum.

As Dan mentioned, the drawing axes in SketchUp is not exposed to the API yet. We have an open issue for this already.

I see only 4 posts total in the Feature Request Forum.(?)
Is there a list somewhere of “open issues” (as tt_su calls it)? or open API feature requests?

I was blindsided last month when I discovered that no font attributes were exposed.

Now this with this no axes pretty much blows my next blockbuster :wink: extension out of the water. I saw the Transformation.axes method months ago and foolishly assumed it would do the job when I needed it. I’ve just wasted 2 weeks work in preparation for using it.

Are people working on these things? Is there a ballpark schedule for implementation?

No - our issue tracker is not public.

Sorry - I cannot give a promise to any timeline.

Do you need just the orientation?

I have used a hack to obtain this for my own extensions:

    # SU7+ only - incorrect in older versions.
    # A hack to get the current model axis.
    # @return [Array<Vector3d,Vector3d,Vector3d>]
    # @since 1.1.0
    def get_local_transformation
      @model.start_operation('Get Local Transformation (Hack)')
      entities = @model.active_entities
      tr = entities.add_group(entities.add_group).transformation tr.xaxis, tr.yaxis, tr.zaxis, ORIGIN )

Note that I’m unable to get the origin.
Also note that this creates a temp operation and should not be used inside of observer events.

The way you safely use it is call this before you start your own operation and then cache the axes orientation.

I’ve used this for Ruby tools where I call this on activate and then cache the axes orientation for later use in the tool - assuming it doesn’t change.

If you do this inside your own operation you must remove the abort operation part and make sure to manually erase the temp group.

This doesn’t help me. I need to actually set new axes, so that the bounds of new groups I create are defined in relation to them.

You want to set the drawing axes in order to control the orientation of your groups?
If that’s the case then you want to create your group normally and then transform it to fit.

Groups are a bit weird because you create the instance directly.
But compare to component instances - you create the definition, then place an instance given a specific transformation.
With groups you’d create the group at origin and then do a transform - same concept.

So the list is secret.
But if someone wastes a sufficient amount of their own time to find an item on the list, only then do you freely admit that it’s on the list.
This is the kind of “secret list” only Franz Kafka could imagine.

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.