Hello,
I need to orient and scale1D a series of objects. I am trying to script it (it has been a few years since I have done it. I have stumbled upon a complicated issue: there is no scale1D as a scripting function. The Rhino.ScaleObject scales according to the Cplane and it seems quite complex to find a cplane after each object is oriented. And I don’t seem to be able to use Rhino.Command with _scale1D.
Any ideas?
N
Hi,
I also got into scale1D problems some time ago.
You might want to try something like @Helvetosaur did:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino, System
def ScaleObjectsEx(object_ids, plane, scale, copy=False):
"""Scales one or more objects. Can be used to perform a uniform or non-
uniform scale transformation. Scaling is based on supplied plane argument.
Parameters:
object_ids: Identifiers of objects to scale
plane: the plane for the transformation
scale: three numbers that identify the X, Y, and Z axis scale factors to apply
copy[opt] = copy the objects
Returns:
List of identifiers of the scaled objects if successful
None on error
"""
scale = rs.coerce3dpoint(scale, True)
if scale:
xform = Rhino.Geometry.Transform.Scale(plane, scale.X, scale.Y, scale.Z)
rc = []
for object_id in object_ids:
object_id = rs.coerceguid(object_id, True)
id = sc.doc.Objects.Transform(object_id, xform, not copy)
if id!=System.Guid.Empty: rc.append(id)
if rc: sc.doc.Views.Redraw()
return rc