Summary: Demonstrates how to rotate an object around the centroid of its bounding box.
The following RhinoScript demonstrates how to rotate an object around the centroid of its bounding box. In this example, we will rotate the object by one (1) degree.
Sub Rotate1 Dim sObj, aBox, aMin, aMax, aCen sObj = Rhino.GetObject("Select object to rotate 1 degree", 0, True) If Not IsNull(sObj) Then aBox = Rhino.BoundingBox(sObj) If IsArray(aBox) Then aMin = aBox(0) aMax = aBox(6) aCen = Array( _ 0.5*(aMax(0)+aMin(0)), _ 0.5*(aMax(1)+aMin(1)), _ 0.5*(aMax(2)+aMin(2)) _ ) Rhino.RotateObject sObj, aCen, 1.0 End If End If End Sub
Here is the button macro version of the above subroutine.
_-NoEcho _-RunScript ( sObj = Rhino.GetObject("Select object to rotate", 0, True) If Not IsNull(sObj) Then aBox = Rhino.BoundingBox(sObj) If IsArray(aBox) Then aMin = aBox(0) aMax = aBox(6) aCen = Array(0.5*(aMax(0)+aMin(0)),0.5**(aMax(1)+aMin(1)),0.5**(aMax(2)+aMin(2))) Rhino.RotateObject sObj, aCen, 1.0 End If End If )