How to scale an object (Green Scale about Opposite Point)

Hello, I’m trying to scale an object which I do manually with Scale tool on a specific point, dragging from Green Scale about Opposite Point, like on the screen:


And dragging from Green Scale about Center, when pressing ‘CTRL’:

I didn’t found in documentation how to scale from that points, but I found this point:

I drew a line between that point and the center of object, and this is the point where “Green Scale about Opposite Point” is situated, I named it in code ‘point_to_scale’.
So I tried to use this method but the result is not what I expected:

  value_to_scale = 1.1
  scale_transform = Geom::Transformation.scaling(point_to_scale, value_to_scale)
  instance.transformation *= scale_transform

Could you help me with an advice how it can be done like with scale tool from SketchUp?
Thank you.

1 Like

When scaling it by 1.1 it makes it 1.1x bigger [in XY&Z].
To ‘flip’ use -1 in the required axial direction.
I appreciate we can’t see all of your code, but a scaling transformation can take various arguments.
So I’m unsure which is which axis of the object - I’ll assume ‘Y’ is the ‘green’ scale your refer to…
In your case perhaps:

cpt = instance.bounds.center
scale = Geom::Transformation.scaling(cpt, 1, -1, 1)
instance.transform!(scale)

See this API page… Class: Geom::Transformation — SketchUp Ruby API Documentation

3 Likes

Thank you for your reply, based on your code, I found solution for my needs.

instance_bb = instance.bounds
tr=instance.transformation
center = instance_bb.center
ip=tr.origin

if is_oriented_on_x
   point_to_scale = [ip.x, center.y, center.z] #for scale about opposite point

   #Green Scale about Opposite Point
   scale = Geom::Transformation.scaling(point_to_scale, value_to_scale, 1, 1)

   #Green scale about Center
   #scale = Geom::Transformation.scaling(center, value_to_scale, 1, 1)
   
 else

   point_to_scale = [center.x, ip.y, center.z] #for scale about opposite point

   #Green scale about Center
   #scale = Geom::Transformation.scaling(center, 1, value_to_scale, 1)

   #Green scale about Opposite Point
   scale = Geom::Transformation.scaling(point_to_scale, 1, value_to_scale, 1)
  
 end