The goal of this exercise is to further the concepts developed in Exercise 02 to create a 3-Dimensional parametric shape through geometric controlling operations. The script created will generate a 3D representation of a user-defined auditorium space.
import rhinoscriptsyntax as rs import math as m #Colors for visualization color01 = [0,0,255] #blue color02 = [255,0,255] #magenta color03 = [255,0,0] #red #THE FOLLOWING VARIABLES ARE FOR GENERATING THE SECTIONAL PROFILES FOR THE STAGE, PERFORMER, CHAIR, AND ROWS/RISERS. #All units are in increments of feet #How many rows are needed? nRows = 6 #What is the height and depth of the Stage? StageH = 4 StageD = 6 #What is the Height of the Performer? PerformerH = 6 #What is the tread depth and riser height of the Row? RowD = 8 RowRiserH = 3 #What is the offset of the front of the chair from the back row riser? SeatOffset = 2.5 #What is the height of the chair seat from the floor? SeatFlrH = 1.5 #What is the depth of the chair seat? SeatD = 2 #What is the height of the chair backrest? BackH = 2.5 #General size (width) of the space AuditW = 50 #Desired number of seats per row nSeatPerRow = 10 def MakeStageProfile (): #The following generates the sectional polyline profile of the stage StageProfile = rs.AddPolyline (([0,0,0] , [0,0,StageH] , [0,-StageD,StageH])) rs.ObjectColor(StageProfile, color01) #The following generates the location of the performer and focal point on the stage FocalH = StageH+PerformerH FocalPt = rs.AddPoint (([0,-3,FocalH])) def MakeRowProfile (): result = [] #The following calculates the sectional polyline profile of the row. RowProfile = rs.AddPolyline (([0,0,0,] , [0,RowD,0,] , [0,RowD,RowRiserH])) result.append (RowProfile) #the following changes the color of the profiles for ease of visualization. rs.ObjectColor(RowProfile, color02) return result def RowArray (): TransX = 0 TransY = RowD TransZ = RowRiserH for i in range(1, nRows): RowTranslation = [i*TransX, i*TransY, i*TransZ] rs.CopyObjects (RowSection, RowTranslation) StageSection = MakeStageProfile () RowSection = MakeRowProfile () FullProfile = RowArray () #join polyline JoinedProfile = rs.JoinCurves (rs.GetObjects("Select Curves to Join", rs.filter.curve)) #create sweep for 3D form def AuditSweep (): rail01 = rs.AddArc3Pt ([0,-6,0], [50, -6, 0], [25,-2,0]) rail02 = rs.AddArc3Pt ([0,50,0], [50, 50, 0], [25,52,0]) rails = rs.GetObjects("Select two rail curve", rs.filter.curve) shapes = rs.GetObjects("JoinedProfile", rs.filter.curve) rs.AddSweep2 (rails, shapes) #The following function generates the seats throughout the surfaces def SeatGenerator (Seat): AuditoriumSweep = rs.GetObjects("Select polysurface to explode", rs.filter.polysurface) ExplodedSurface = rs.ExplodePolysurfaces(AuditoriumSweep, True) for i in range (3, nRows*2, 2): exsf = ExplodedSurface[i] domainU = rs.SurfaceDomain(exsf, 0) domainV = rs.SurfaceDomain(exsf, 1) uParam = domainU [0] / 5 vParam = domainV [1]*.75 crv = rs.ExtractIsoCurve(exsf, (uParam, vParam), 0) SeatPoint = rs.EvaluateCurve (crv, uParam) rs.CopyObjects (Seat, SeatPoint) for j in rs.frange (0, AuditW, (AuditW/nSeatPerRow)): SeatPoint = rs.EvaluateCurve (crv, vParam) rs.CopyObjects (Seat, SeatPoint) Auditorium = AuditSweep () MySeat = rs.GetObject("Select Seat to Copy") SeatGenerator (MySeat)