From c5f3dd1bad48330fcfa9a4ebfb43a9bb78c6384c Mon Sep 17 00:00:00 2001 From: Dale Fugier Date: Mon, 30 Jul 2018 09:17:00 -0700 Subject: [PATCH] Added SampleArrayCrv.py --- rhinopython/SampleArrayCrv.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 rhinopython/SampleArrayCrv.py diff --git a/rhinopython/SampleArrayCrv.py b/rhinopython/SampleArrayCrv.py new file mode 100644 index 00000000..77cc88b7 --- /dev/null +++ b/rhinopython/SampleArrayCrv.py @@ -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() \ No newline at end of file