Move many component / group axes to model origin without affecting their geometry

I have many components in a model and want to mass-relocate all their individual axes to the 0,0,0 model origin. The axes would also need to be rotated so as to align with the model origin axis as well.

Here is the script I’m working with - which has issues: (its a Chat GTP output.)

require 'sketchup'

# Function to set the axes of a component or group to the origin
def set_axes_to_origin(entity)
  # Get the transformation of the entity
  tr = entity.transformation
  # Create a new transformation that only changes the axes
  new_transformation =, tr.yaxis, tr.zaxis, ORIGIN)
  # Set the new transformation to the entity
  entity.transformation = new_transformation

# Main script
model = Sketchup.active_model
entities = model.active_entities
ORIGIN =,0,0)

# Start an operation that can be undone in one step
model.start_operation('Set Axes to Origin', true)

# Iterate through entities in the model
entities.each do |entity|
  # Check if the entity is a group or component instance
  if entity.is_a?(Sketchup::Group) || entity.is_a?(Sketchup::ComponentInstance)

# Commit the operation

puts "Axes of all components and groups have been set to the origin."

All this does is to move all model groups and components to the 0,0,0 point, when what I want is to merely move the axes here.

Any ideas?

there allready is an extension for this:

Edit: This extension moves the components to the origin, basically what you allready have…

Edit 2: Do you mean you want to leave the components in place and move only their axes to the origin?
1: Why do you want to do that?
2: Be aware that having the components axis a long way from the components geometry can sometimes cause trouble. The same applies to components with their axis close by that are a great distance from the origin.

1 Like

Thanks so much - I was on Sketchucation looking for this but somehow missed it. The use case will not be moving component axes very far.

1 Like

I’m still curious about why you would want to move all of them to the origin…

1 Like

I’m exporting them all to Lumion and will be pulling in each one in a phased animation. The component axes have to be in the same place for the whole thing to start and finish correctly.


Save the current transformation:

t = grp.transformation

Remove the instance’s transformation:

grp.transform!( t.inverse )

Now, transform the grp definition’s entities:

ents = grp.definition.entities
ents.transform_entities(t, ents.to_a)

This will affect ALL instances of a group or component. If there are multiple instances, then the code will need to make each have a unique definition before doing any of the above. Ie …

grp.make_unique if grp.definition.instances.size > 1
# ... Adjust the axes per above ...