Global Axis Ruby plugin

Is it possible to move the Axis to achieve what is on the video?

1 Like

I don’t understand 100% what you want to do, but “moving the axes back and forth” can be done something like this:

Class: Sketchup::Axes

model = Sketchup.active_model
# "Save" the current axes data:
o_origin, o_xaxis, o_yaxis, o_zaxis = model.axes.to_a

#Determine the new x axis and origin location:
# (example point and vector, you have to get it e.g.
#   vertex and edge line...)
new_origin =,20,0) 
new_xaxis =, 5, 0)
# Use original z axis and calculate y axis
new_zaxis = o_zaxis
new_yaxis = new_zaxis * new_zaxis

# Set the new axes
model.axes.set( new_origin, new_xaxis, new_yaxis, new_zaxis )

# Do your "followme" stuff

#"Reset" the axes to saved one:
model.axes.set( o_origin, o_xaxis, o_yaxis, o_zaxis )

Administrative notices:
Please complete your forum profile!
Don’t cross-post the same thing in multiple topics.

1 Like

1 - First of all, repeating @dezmo re. cross posting. The admins have deleted your extraneous post in that old topic. Please review the forum rules.

2 - Re your topic title “Global Axis …”

Axes is plural. Axis is singular. The axes consists of 3 axis and an origin.

The global (or “world” or “model”) axes cannot be changed.
It is fixed and in Ruby is already referenced at the top level as ORIGIN, X_AXIS, Y_AXIS and Z_AXIS.

Note, that the SketchUp API documentation also may call this the “root” model axes (or transformation.)

So there is actually no need to save the root model axes like so …

# "Save" the current axes data:
o_origin, o_xaxis, o_yaxis, o_zaxis = model.axes.to_a

… because you can always do …

def reset_axes_to_root( model = Sketchup.active_model )
  model.axes.set( ::ORIGIN, ::X_AXIS, ::Y_AXIS, ::Z_AXIS )

3 - What you are asking to do and what @dezmo is describing, is the manipulation of the user Drawing Axes. This is analogous to AutoCAD’s User Coordinate System (aka UCS).

When you first start an new empty model, the Drawing Axes is initially set to match the “root” model axes.

Both the user and Ruby extensions can change the current Drawing Axes at any time. So, @dezmo’s axes saving example does have validity, if your code needs to save the current axes settings and restore them after your code does what it does with a temporary drawing axes setting.

The Sketchup::Axes class documentation tells us that native tools are already written to honor the Drawing Axes.

It is the responsibility of the SketchUp extension developer to write code (either geometry commands or tools) that honor the current drawing axes. This is explained in the documentation and code snippet for the Sketchup::Axes#transformation method. (Note that the comment in the code snippet is a bit hard to understand. Filed API Issue #789 to correct the code example and it’s commentary.)

4 - Whenever asking about a specific model scenario, please post the test model with your question.

Ie, it is not evident in the video if the cuboids are all primitives or groups (or component instances.)

If they were instances or groups (which are really special instances) they themselves have a transformation, which has there own origin and axes.

5 - The last question about determining a profile extrusion (followme) path along parts of multiple objects is a separate and very complex problem that deserves a topic all to itself.

ADD: We ask that coders at least make an attempt to solve their challenges.
It is poor etiquette to post asking for others to do your work for you without first trying.

1 Like