suppose to we have a box component that orbited 45 degree in Z , so his X and Y axis is not match in world coordinate and this make mistake when i scaled X axis by this code :
Hamed, This is a general problem and may happen many times. When you want to write some code for a group or component you’d better move it to the original coordinate and after finish codes return it back.
sele = Sketchup.active_model.selection[0]
# Save the current transformation:
xform = sele.transformation
# Revert the current transformation:
sele.transform!(xform.inverse)
# Create a new compound transformation with scaling:
compound_xform = Geom::Transformation.scaling(xform.origin, 2, 1, 1) * xform
# Apply the compound transformation:
sele.transform!( compound_xform )
@majid866, your code is being applied to the definition’s entities which will effect ALL instances rather that the instance selected.
Dear Dan, I should learn more from you. I run your code for a box and you can see the result in the video. Would you please let me know about the problem?
The problem is that it did not do what I hoped it would. It skewed the instance instead.
So the answer was to apply the scaling transform first, then apply the original transform afterward.
(The original transform was a compound with both rotation and transition.)