Thursday, August 27, 2009

Using functions


import py2rhino as p2r
print p2r._version
#------------------------------------------------------------------------------
#global variables
points = ((0,0,0), (0,10,0), (10,10,0))

#------------------------------------------------------------------------------
def create_base():
return p2r.obj.Polyline.create(points)

def extrude_base(base):
start = (0,0,0)
end = (0,0,10)
return p2r.obj.NurbsSurface.create_by_extrude_crv_straight(base, start, end)

def copy_and_rotate_srf(srf):
srf_copy = srf.dupl.copy_move_by_vec((0,0,10))
srf_copy.trfm.rotate( (0,0,0), 5, (0,0,1))
return srf_copy

#------------------------------------------------------------------------------
base = create_base()
srf = extrude_base(base)

for i in range(10):
srf = copy_and_rotate_srf(srf)

1 comment:

  1. can i know how to use the PASS command that u mentioned on monday? I wanted to draw vertical lines on the points of a flat curve. I created a function to draw 1 line successfully but i cant make the function draw lines on different points. Can all lines on different start points be drawn using 1 function, or do i need to create individual functions for each line?

    thank you in advance! :)

    ReplyDelete