Kami – 06 CLASS


import rhinoscriptsyntax as rs
import math

class myPolygon:

def __init__(self, radius, sides):
self.radius = radius
self.sides = sides
theta = (2*math.pi)/self.sides
pt01 = rs.AddPoint(self.radius, 0, 0)
pts = []
pts.append(pt01) #adding this to the empty list
self.origin = [0,0,0] #origin variable as a property of polygon
#this is bc we will later change this origin point
degrees = theta*(180/math.pi)

#want to add other points
#to do so use rptate object method in rhino
#to rotate these points around based on angle theta
#for a certain number of times, so need loop:

for i in range(1, self.sides):
tempPt = pts[-1] #to use very last pt in list of pts
newPt = rs.RotateObject(tempPt, self.origin, degrees, None, True)
pts.append(pt01) #to end, add the first point
self.polygon = rs.AddPolyline(pts)
def fillPolygon(self):
return rs.AddPlanarSrf(self.polygon)

def extrudePolygon(self, height):
startPt = self.origin
#this is taking the third value of the origin coordinate (z-value):
newZ = self.origin[2]+height
endPt = self.origin[0], self.origin[1], newZ
return rs.ExtrudeCurveStraight(self.polygon, startPt, endPt)

polygon1 = myPolygon(5,5)
polygon2 = myPolygon(6,6)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s