Currently rs.XformScale only allows scaling in the world coordinate system. There is a RhinoCommon transform method that allows scaling based on an arbitrary plane.
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.transform/scale
(first overload)
The funny thing is the rhinoscriptsyntax method actually uses the above RhinoCommon variant, but then shuts it off…
def XformScale(scale, point=None):
factor = rhutil.coerce3dpoint(scale)
if factor is None:
if type(scale) is int or type(scale) is float:
factor = (scale,scale,scale)
if factor is None: return scriptcontext.errorhandler()
if point: point = rhutil.coerce3dpoint(point, True)
else: point = Rhino.Geometry.Point3d.Origin
plane = Rhino.Geometry.Plane(point, Rhino.Geometry.Vector3d.ZAxis);
xf = Rhino.Geometry.Transform.Scale(plane, factor[0], factor[1], factor[2])
return xf
So it could easily be made to accept a point or a plane as an argument… Like this I think:
def XformScale(scale,origin=None):
factor = rhutil.coerce3dpoint(scale)
if factor is None:
if type(scale) is int or type(scale) is float:
factor = (scale,scale,scale)
if factor is None: return scriptcontext.errorhandler()
plane=Rhino.Geometry.Plane.WorldXY
if origin:
if isinstance(origin,Rhino.Geometry.Plane):
#a plane was passed
plane=origin
else:
point=rhutil.coerce3dpoint(origin)
if point:
#a point was passed, move world XY plane origin to point
plane.Origin=origin
xf = Rhino.Geometry.Transform.Scale(plane, factor[0], factor[1], factor[2])
return xf
Or, add a plane as a second optional argument, but I think the above would be better (just change the Help…)