PDA

View Full Version : Function AddRectangle



vittorio
05-17-2010, 04:14 PM
# draw rectangle
# write by Vittorio Carlotto 2010-05-16
# Bassano del Grappa Italy



import rhinoscriptsyntax as rs

def AddRectangle(x,y,pt):
arrplane=rs.ViewCPlane()
p1=[0,0,0]
p2=[x,0,0]
p3=[x,y,0]
p4=[0,y,0]
origine=rs.XformCPlaneToWorld(p1,arrplane)
arrpC=[p1,p2,p3,p4,p1]
arrpW=[]
for pc in (arrpC):
pw=rs.XformCPlaneToWorld(pc,arrplane)
arrpW.append(pw)
newArrW=[]
for pp in arrpW:
newp=[]
for cc,pc,co in zip (pp,pt,origine):
newc=cc+pc-co
newp.append(newc)
newArrW.append(newp)
idRectangle=rs.AddPolyline(newArrW)
return idRectangle

if( __name__ == '__main__' ):
point=rs.GetPoint("Origin Point")
x=100
y=50
AddRectangle(x,y,point)

Hi all
This is a function that draw a rectangle.Steve if you want you can insert it into rhinoscript.curve
I invite members to improve the function , i would be happy
Ciao Vittorio