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(newPt)
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)
polygon1.fillPolygon()
polygon2.extrudePolygon(10)

### Like this:

Like Loading...

*Related*