Welcome to the Rhino 7 version of this page! Looking for the newer Rhino 8 WIP version?

Polar Arrays

Demonstrates how to create polar arrays of objects using RhinoScript.


Option Explicit

Sub MyArrayPolar

  Dim arrObjects, arrCenter, nCount
  Dim dAngle, arrAxis, arrXform, i

  arrObjects = Rhino.GetObjects("Select objects to array")
  If IsNull(arrObjects) Then Exit Sub

  arrCenter = Rhino.GetPoint("Center of polar array")
  If IsNull(arrCenter) Then Exit Sub

  nCount = Rhino.GetInteger("Number of items",,2)
  If IsNull(nCount) Then Exit Sub

  dAngle = 360.0 / nCount

  Rhino.EnableRedraw False

  For i = 1 To nCount - 1
    arrAxis = Array(0,0,1) ' world z-axis
    arrXform = Rhino.XformRotation(dAngle * i, arrAxis, arrCenter)
    Rhino.TransformObjects arrObjects, arrXform, True

  Rhino.EnableRedraw True

End Sub