My First RhinoPython Script
by
on 07-06-2011 at 04:14 PM (3631 Views)
I know this is kinda cheezy, since I use the RhinoScript syntax. But hey! gotta start somewhere...
Python Code:
################################################################################ ArchimedeanSpiral.py -- July 2011# If this code works, it was written by Dale Fugier.# If not, I don't know who wrote it.## Change 'a_const' to turn the spiral.# Change 'b_const' to control the distance between turnings.import rhinoscriptsyntax as rsdef ArchimedeanSpiral():print "Archimedean Spiral: Radius = A + B * Theta"a_const = rs.GetReal("Value of A constant", 1.0, 0.01)if a_const is None: returnb_const = rs.GetReal("Value of B constant", 1.0, 0.01)if b_const is None: returnnum_points = rs.GetInteger("Number of points to calculate", 10, 1)if num_points is None: returnstep_angle = rs.GetReal("Angle between points", 30.0, 1.0, 45.0)if step_angle is None: returncurr_angle = 0.0base_point = [0.0, 0.0, 0.0]points = []for i in xrange(0, num_points):radius = a_const + (b_const * curr_angle)pt = rs.Polar(base_point, radius, curr_angle)points.append(pt)curr_angle = curr_angle + step_anglers.AddInterpCurve(points)########################################################################### 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.if( __name__ == "__main__" ):ArchimedeanSpiral()
Enjoy!




Email Blog Entry
