Though the intent of the previous exercise was to a create the 3D surface in which seating layouts can be arranged upon, the objective of Exercise 04 is to [/sourcecode] make use of the visual representation. The script in this exercise extracts structural data information from the generated 3D surfaces and manage that data to execute a seating layout that can not only be arranged upon such surfaces but also is able to be customized to fit user’s needs.
import rhinoscriptsyntax as rs import math as m #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 #General size (width) of the space AuditW = 50 #Desired number of seats per row nSeatPerRow = 10 #function for creating 2D profile of stage. def StageProfile (): #The following generates the sectional polyline profile of the stage StageProfile = rs.AddPolyline (([0,0,0] , [0,0,StageH] , [0,-StageD,StageH])) blue = [0,0,255] rs.ObjectColor(StageProfile, blue) #The following generates the location of the performer and focal point on the stage FocalH = StageH+PerformerH return StageProfile #function for creating 2D profile of the first row. def RowProfile (): result = [] #The following generates the sectional polyline profile of the first row. Row = rs.AddPolyline (([0,0,0,] , [0,RowD,0,] , [0,RowD,RowRiserH])) result.append (Row) #the following changes the color of the profiles for ease of visualization. magenta = [255,0,255] rs.ObjectColor(Row, magenta) return result #function for creating array from the first row's profile. def RowArray (Curve): result = [] result.append (Curve) TransX = 0 TransY = RowD TransZ = RowRiserH for i in range(1, nRows): RowTranslation = [i*TransX, i*TransY, i*TransZ] result.append (rs.CopyObjects (Curve, RowTranslation)) return result #function for creating 3D sweep from joined 2D profile. def AuditSweep (): return (rs.AddSweep2 (rails, JoinedProfile)) #function for finding locations of seats at the first row. def SeatPathPoints (rail, nSeats): SeatPoints = [] divs = rs.DivideCurve (rail, (nSeats*2)) for i in range (1, len(divs),2): SeatPoints.append (divs[i]) return SeatPoints rs.AddPoints (SeatPoints) #function for copying seats to each Seat Path Point def CopySeats (Seat, Points): result = [] RefBox = rs.BoundingBox (Seat) RefLine = rs.AddLine (RefBox[0], RefBox[2]) RefPt = rs.DivideCurve (RefLine,2)[1] rs.DeleteObject (RefLine) for pt in Points: CopyVect = rs.VectorCreate (pt, RefPt) result.append (rs.CopyObject (Seat, CopyVect)) return result #function for copying rows def CopyRow (Row, Profile): RefBox = rs.BoundingBox (Row) RefPt = RefBox[0] results = [] Curves = rs.ExplodeCurves (Profile) for i in range (2, len(Curves), 2): Pt = rs.DivideCurve (Curves[i],RowD,False,True)[4] CopyVect = rs.VectorCreate (Pt, RefPt) result = rs.CopyObjects (Row, CopyVect) results.append (result) Stage = StageProfile () FirstRow = RowProfile () FullProfile = RowArray (FirstRow) FullProfile.append (Stage) JoinedProfile = rs.JoinCurves (FullProfile) origin = [0, -6, 0] rail01 = rs.AddArc3Pt ((origin), [50, -6, 0], [25,-2,0]) rail02 = rs.CopyObject (rail01,[0,50,0]) rails = [rail01, rail02] MyAuditorium = AuditSweep() MySeat = rs.GetObject("Select Seat") MyRowSeatPoints = SeatPathPoints (rail01,nSeatPerRow) MyRow = CopySeats (MySeat, MyRowSeatPoints) CopyMyRow = CopyRow (MyRow, JoinedProfile) rs.DeleteObjects (MyRow) rs.DeleteObject (MySeat) rs.DeleteObjects (rails) #end