How to perform stretch (On Red Axis Outside Active)

Hello, I am trying to perform stretch operation on a face from a component. Like with Move Tool in SketchUp.
So, first off, I select the face i want to stretch,


and after using Move Tool I select the direction to stretch my face,

till appears near the mouse “On Red Axis Outside Active”.
And one more example to be better understood:

Is it possible to perform this operation in ruby, or something similar?
Thanks in advance for your help!

Yes, you can do this without user interaction by transforming the vertices of the selected face using the Sketchup::Entities#transform_entities method. You pass an array of the face’s vertex objects into the method (as the 2nd argument) following the transform (1st) argument.

In this case the transform argument would be based upon a vector pointing along Y_AXIS (the global model y axis,) or along the parent context’s y axis of the group.

Something like this (note, this is untested.)

# Where "face" is a reference to the face to be transformed,
# and "offset" is a length to offset the face's vertices in the y direction ...

# Find the y axis vector for the transformation:
if model.active_entities == model.entities || model.active_path.size < 2
  y_vector = Y_AXIS.clone
else
  parent = model.active_path[-2]
  y_vector = parent.transformation.yaxis
end

# Set the length of the y_vector for the offset desired:
y_vector.length= offset

# Create the translational tranformation using this vector:
y_transform = Geom::Transformation.translation(y_vector)

# Transform face's vertices using the y_transform:
model.active_entities.transform_entities( y_transform, face.vertices )

If you are interested in coding a custom Ruby Stretch tool that will incorporate user interaction, it is quite complex and involves understanding the inference engine. There are examples on GitHub for custom tools.

1 Like