top of page
  • Writer's pictureDavid Mans

Transform Each

💻 Rhino 5

🔼 Rhino Script

🛠️ Visual Basic

 

It may be a very simple script, but it is a handy one to have around. The command is modeled after adobe Illustrator’s transform each feature and follows its namesake.

 
Option Explicit
'Script written by <David Mans>
'Script copyrighted by <Neoarchaic Design>
'Script version Thursday, April 10, 2008 11:13:06 PM
 
Call Main()
Sub Main()
    Dim objects
    objects = Rhino.GetObjects("Select Objects")
    If isNull(objects) Then Exit Sub
    Call Rhino.enableredraw(False)
    transformEach(objects)
    Call Rhino.enableredraw(True)
End Sub
Function transformEach(objects)
    transformEach = Null
    Dim arrItems, arrValues, arrReturns
    arrItems = array("rotate_X", "rotate_Y", "rotate_Z", "scale_X", "scale_Y", "scale_Z")
    arrValues = array(0, 0, 0, 1, 1, 1)
    arrReturns = Rhino.PropertyListBox(arrItems, arrValues,, "Transform Parameters")
    If isNull(arrReturns) Then Exit Function
    Dim i,count
    Dim bBox,tempLn,origin,world
    count = uBound(objects)
    For i = 0 To count Step 1
        'determine each objects center
        bBox = Rhino.BoundingBox(objects(i))
        tempLn = Rhino.AddLine(bBox(0), bBox(6))
        origin = Rhino.CurveMidPoint(tempLn)
        world = Rhino.WorldXYPlane()
        'if scale values have been changed scale each object according to each of the three independent world axis
        If arrReturns(3) <> 0 Or arrReturns(4) <> 0 Or arrReturns(5) <> 0  Then
            Call Rhino.ScaleObject(objects(i), origin, array(CDbl(arrReturns(3)), CDbl(arrReturns(4)), CDbl(arrReturns(5))))
        End If
        'if rotation values have been changed rotate each object about its local world based axis
        If arrReturns(0) <> 0 Then
            Call Rhino.RotateObject(objects(i), origin, CDbl(arrReturns(0)), world(1))
        End If
        If arrReturns(1) <> 0 Then
            Call Rhino.RotateObject(objects(i), origin, CDbl(arrReturns(1)), world(2))
        End If
        If arrReturns(2) <> 0 Then
            Call Rhino.RotateObject(objects(i), origin, CDbl(arrReturns(2)), world(3))
        End If
         
        Call Rhino.DeleteObject(tempLn)
    Next
End Function
 


4 views

Recent Posts

See All
bottom of page