When execute $dc_observers.get_latest_class.redraw_with_undo element the element translate to the old position too.
Is there a way to “commit” this transformation?
Because you are transforming the definition’s entities with respect to the origin of the definition. So you are moving the objects away from the component origin.
Apply the translation transformation to the component instance instead.
if element.is_a?(Sketchup::ComponentInstance)
element.transform!(Geom::Transformation.translation([0, 12, 0]))
end
P.S.: Only global methods defined in Kernel and Object should be called without wrapping the arguments in parentheses.
I need to move a rotated element in your own x,z axis, that’s why I’m using Entities#transform_entities.
With element.transform! if the element is rotated 45º, for example, when perform translation[0,12,0] the element won’t move in diagonal in relation to the global axes.