Rhino.Script: Array around curve

rhinoscript-array-around-curve-1_2

The following script allows you to array an object around a curve and designate a rotation.

You will need to do the following to execute the script

1. Select an object.
2. Set the “cplane” by designating 3 points (origin, X, Y)
2. Select a “curve” the array will occupy
3. Select the # in your array
4. Designate the degree of rotation.

  1. Option Explicit'Script written by David Mans http://www.neoarchaic.net
  2. 'Script copyrighted by core.form-ula under Creative Commons
  3. 'Script version Tuesday, September 09, 2008 2:59:56 PM
  4.  
  5. Call Main()
  6.  
  7. Sub Main()
  8.  
  9. Call arrayRotateAboutCurve()
  10.  
  11. End Sub
  12.  
  13. Function arrayRotateAboutCurve()
  14.  
  15. arrayRotateAboutCurve = Null
  16.  
  17. Dim i,j, objects,angle, originPln, steps, curve, pt(2), dom, crvFrame, rotFrame
  18.  
  19. objects = Rhino.GetObjects("Select Objects")
  20.  
  21. If isNull(objects) Then Exit Function
  22.  
  23. pt(0) = Rhino.GetPoint("Select Origin Point")
  24.  
  25. If isNull(pt(0)) Then Exit Function
  26.  
  27. pt(2) = Rhino.GetPoint("Select Point for X Axis")
  28.  
  29. If isNull(pt(2)) Then Exit Function
  30.  
  31. pt(1) = Rhino.GetPoint("Select Point for Y Axis")
  32.  
  33. If isNull(pt(1)) Then Exit Function
  34.  
  35. originPln = Rhino.PlaneFitFromPoints(pt)
  36.  
  37. curve = Rhino.GetObject("Select Curve",4)
  38.  
  39. If isNull(curve) Then Exit Function
  40.  
  41. steps = Rhino.GetReal("Count",10)
  42.  
  43. If isNull(steps) Then Exit Function
  44.  
  45. angle = Rhino.GetReal("Rotational Increment", 15)
  46.  
  47. If isNull(angle) Then Exit Function
  48.  
  49. Call Rhino.EnableRedraw(False)
  50.  
  51. Call rhino.SelectObject(curve)
  52.  
  53. Call rhino.Command("reparameterize 0 1")
  54.  
  55. Call rhino.UnselectAllObjects()
  56.  
  57. dom = Rhino.CurveDomain(curve)(1)
  58.  
  59. For i = 0 To steps Step 1
  60.  
  61. crvFrame = Rhino.CurvePerpFrame(curve,(dom/steps)*i)
  62.  
  63. rotFrame = Rhino.RotatePlane(crvFrame,angle*i,crvFrame(3))
  64.  
  65. For j = 0 To uBound(objects) Step 1
  66.  
  67. Call Rhino.OrientObject(objects(j),pt,array(rotFrame(0),Rhino.PointAdd(rotFrame(0),rotFrame(1)),Rhino.PointAdd(rotFrame(0),rotFrame(3))),1)
  68.  
  69. Next
  70.  
  71. Next
  72.  
  73. Call Rhino.EnableRedraw(True)

Rhino.Script: Array around curve

via core.form-ula

Creative Commons License

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

Leave a comment

You must be logged in to post a comment.