Skip to content

Commit

Permalink
Added SampleArrayCrv.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dalefugier committed Jul 30, 2018
1 parent fe51749 commit c5f3dd1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions rhinopython/SampleArrayCrv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
################################################################################
# SampleArrayCrv.py
# Copyright (c) 2018 Robert McNeel & Associates.
# See License.md in the root of this repository for details.
################################################################################
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

# Array selected objects along a curve
def SampleArrayCrv():

obj_ids = rs.GetObjects("Select objects to array")
if not obj_ids: return

base_pt = rs.GetPoint("Base point")
if not base_pt: return

plane = rs.ViewCPlane()
plane.Origin = base_pt

crv_id = rs.GetObject("Select path curve")
if not crv_id: return

count = rs.GetInteger("Number of items", 2, 2)
if not count: return

if rs.IsCurveClosed(crv_id): count -= 1

crv_t = rs.DivideCurve(crv_id, count, False, False)
for t in crv_t:
frame = rs.CurveFrame(crv_id, t)
xform = rs.XformRotation1(plane, frame)
rs.TransformObjects(obj_ids, xform, True)

# Check to see if this file is being executed as the "main" python
# script instead of being used as a module by some other python script
# This allows us to use the module which ever way we want.
SampleArrayCrv()

0 comments on commit c5f3dd1

Please sign in to comment.