Generative systems MSc3 Design Studio Workshop Series
9th
1st Workshop to 13th of September 2013 TU Delft Faculty of Architecture AE+T, HRG
Sougnmin Yu – Sina Mostafavi
Schedule Day1: Monday, 9/9 Lecture: Design ,Generative Systems And Design Computation Practice: OOP, Scripting, Rhino And Python Practice : Recursion And Iteration Design: Q&A, Group Brainstorming Session Day2: Tuesday, 9/10 Lecture: Implementations, State Of The Art, Case Introduction And Analysis Design: Design Brief Clarification Practice: More On OOP And Python In Grasshopper Practice : More On Recursion And Code Interpretation Design: Process Design, Site Studies, Pseudo Code Design Day3: Wednesday, 9/11 Lecture: L-systems, Theory And Implementations Practice: L-system Algorithms , Code Analysis Design: Design Hints, Initial Digital Prototyping, And Design Process Development Day4: Thursday, 9/12 Lecture: Cellular Automata, Complex Systems And Bottom-up Design Approaches Practice: CA Algorithms, Tests And Code Analysis Design: Digital Prototyping, Algorithm Developments Day5: Friday, 9/12 Design: Group Discussions, Design Process Enhancement Practice: Debugging Sessions Design: Groups Presentations
Day1 Content
Theoretical Framework
Design ,Generative Systems And Design Computation On Taxonomy Of Computational Design
Introduction on OOP and Python Python Is This And That Variables, List, Tuples, Dictionaries, Etc. Function Conditionals Loops
Recursion Example 1 Example 2
References
THEORETICAL FRAMEWORK
Questions?
What do we mean by generative systems ? What can be a proper design method to apply generative systems in design? What are the techniques we need to apply generative systems in design? To which extent generative systems can be considered an applied as bottom up decision making approaches in architectural design? Conditionals , recursive, iterative, L-systems, cellular automata and agent-based modelling; what are these concepts in algorithmic thinking , and how they can be integrated and applied in architectural design processes?
Hypothesis and Objective We are thinking of a rational, at the same time creative design process in which proper methods of generation and performance mapping and estimation can be applied. If we become familiar with more advanced bottom up methods of form finding, in tune with nature and characteristics of our design ideas, we can equip ourselves with proper computational design methodologies. In a theoretical framework like this, every aspects of design can be considered as systems. Then, The goal is to integrate generative systems with evaluation systems. Behind the importance of the functionalities of the customized, developed and implemented algorithms, the information models and methodical data exchange is at the very core of our design process.
Generative Systems
+
Evaluation System
…
Material Computation Physical Computing
Environmental computing Associative modeling
Smart Geometry Constraint Based Modeling Shape Grammar Design Computation
Information Modeling Visualization Spatial Computing Behavioral Computing
Human Computer Interaction Deign Interface …
There are many research fields in The realm of design computation! What are the common aspects in these fields and corresponding design methodologies? How having an understanding of the taxonomy of computational design can help us as designers to choose, develop and design a proper workflow?
So we need to know about The-state-of-the-art Study some of the relevant examples Project in academia and practice Interpret and analyse them
INTRODUCTION ON OOP AND PYTHON
• • • • • • • • • • • •
Python is an Object Oriented Programming(OOP) Language Python is a high level programing language Python doesn’t need variable type declaration Python is indent sensitive language Python does not need too many punctuations Python is a case sensitive language Python is in Rhino, Revit, Maya, ArcGIS… Python is that Python is this mmm… Python is here I am saying… Python is there Python is …
hmm… But can you understand that machine?
Python is an OOP: Object-Oriented Programming Language: Object is module created by a programmer or you Objects are grouped into classes Objects have members called: properties and methods A property describes the object while a method is something that can be done to an object ………… …….
OBJECT
PROPERTY Attribute or state
METHOD
Do something: Function & Procedure
Rhino Python Editor is an Integrated Development Environment or Interactive Development Environment
IDE)
(
Help us to have automatic access to embedded libraries and documentations and to develop and debug our code It works like the way Monkey Script editor in Rhino for Visual Basics(VB)
With Rhino Python Editor you have access to .NET framework? It means that you can access to huge sources of libraries and you eventually you can make your own tool!
A programming infrastructure created by Microsoft for building deploying, and running applications and services that use .NET technologies such as desktop applications and Web Services
Some fundamental concepts and definitions
Variables: Are storage locations for known or unknown quantity of information Integers: 1,-33,555,2000000000 Floats and Doubles: 1.55, 45.5553, -0.3355 Booleans: True, False Strings: “Hello World”, ”S” None:
Lists: Are collection or set of things You show them with this symbol : [ ] You can store lists, tuples, integers, strings in lists Lists are mutable or changeable You can add change or remove elements in the lists We have many methods for lists manipulation: append(),insert(), sort(), reverse(), index(),etc. …
List_1 = [1,3,5,7] List_2 = [2,”Hello”,”Hello World”, “etc.” ,[888,88,888,88,888,88]]
Tuples Are collection or set of things You show them with this symbol : ( ) You can store lists, tuples, integers, strings, dictionaries, etc. in tuples Tuples are immutable or are not changeable … T_1 = (1,3,5,7) My_Tuple_2 = ((0,0,0),”Hello”,”Hello World”, “etc.” ,[888,88,888,88,888,88])
Dictionaries Are collection or set of things with keys and values You show them with this symbol : { } In a dictionary like this: {K1:V1,K2:V2,….,Kn:Vn}, K letters are keys and V letters are values You can call a values through the keys Keys can be any immutable thing like string, integers or tuples, and values can either be mutable or immutable like lists, dictionaries, strings, etc. Dictionaries are mutable, you can add or remove elements … Dict_1 = {X:1, Y:11, Z:111, U:1111} Dict_2= {A:[1,[1,1]], Y:[1,[1,1],[1,1,1]]} DIct_1[Y] +Dict_1[Z]>>> 121
Operators Are elements in a program that are usually used to assist in testing conditions
OR, AND, NOR, XOR, ==, >,>=, etc. are examples of operators The return of these comparison or operations is/are True(s) and False(s) value(s) Python has its own syntax for different types of operators You can use Venn Diagrams to represent the Boolean operations
Operators are elements in a program that are usually used to assist in testing conditions
Conditionals Are statements evaluates a Boolean condition We have different types of conditional structures in python like, if-else, if-elif-else Python has its own syntax, and indentation for conditionals We can have nested conditional statement and we can have conditional loops A simple conditional statement in python can be written like this: If (condition1(expression)): Do something(statement) elif (condition2(expression)): Do something(statement) else: Do something (statement)
Loops Are statements that allows code to be repeatedly executed Loop is classified as an iteration statement. In python We have for loops and while loops and you can use different types of syntax for loops While loop are conditional loops and We can also nest conditionals in for-loops We can have loops in loops, which we call them nested loops nested loops can generate 1D, 2D, 3D or ND arrays of objects Some of loop structures in python can be written as follows:
count = 0 while (count < 10): print 'The count is:', count count = count + 2 for i in range(1,10): print i for I in range (1,10,2): for j in range(1,5): print (i,j) List = [1,2,33,34] for item in list: print item
Function Or subroutine is is a sequence of program instructions that perform a specific task, packaged as a unit. You can call a functions when you need them to perform Python has its specific syntax and indentation for functions A simple example of functions in python can be written as follows: import rhinoscriptsyntax as rs def addpointFunction(x): if x==0:return else: ipoints=[] for i in range (0,x): point=rs.AddPoint([i,i,i]) ipoints.append(point) allthepoints.append(ipoints) addpointFunction(x-1) allthepoints=[] addpointFunction(3) print allthepoints[0][2] print len(allthepoints)
Letâ&#x20AC;&#x2122;s try with some examples! And please install the needed software and add-ons
Example 1, Variable assignation
Str = "Generative SYSTEMs" print (Str) >>> Generative SYSTEMs Example 2, Import libraries and access to their methods, Bug!
import math x = 5.6666 x = math.sqrt(x) print x print math.cos(x) print math.abs(x) 2.38046214001 -0.724056712662 Message: 'module' object has no attribute 'abs' Traceback: line 8, in <module>, "C:\Users\smostafavi\AppData\Local\Temp\TempS cript.py"
It doesn’t work! Then what to do? First keep Calm! And Then…
import math as m x = 5.6666 x = m.sqrt(x) print x print m.cos(x) print m.fabs(m.cos(x)) 2.38046214001 -0.724056712662 0.724056712662
Now it works!
The more you become familiar with documentation The more you can write correct algorithms “Turn pseudo codes to final codes” And develop your design tools However you don’t have to memorize it!
Example 3 on Tuples import math t = "Froyd!",1.2234566, (0,0,0,0,0,0), " IN THIS TUPLE!!!!" print print print print print print
", 444, math.pi,444,"THIS SENTENCE IS THE LAST ITEM
":What you have in the t tuple:\n",t "The second Item in you tuple is", t[1] "44 has happend ",tuple.count(t,44), " time(s)" "444 has happend ",tuple.count(t,444), " time(s)" "the lenth of the tuple is: " ,len(t) "the last item in your tuple is: ",t[len(t)-1]
#AND MANY MORE FUNCTIONS FOR TUPLES!
:What you have in the t tuple: ('Froyd!', 1.2234566, (0, 0, 0, 0, 0, 0), ' ', 444, 3.141592653589793, 444, 'THIS SENTENCE IS THE LAST ITEM IN THIS TUPLE!!!!') The second Item in you tuple is 1.2234566 44 has happend 0 time(s) 444 has happend 2 time(s) the lenth of the tuple is: 8 the last item in your tuple is: THIS SENTENCE IS THE LAST ITEM IN THIS TUPLE!!!!
And now what about this!
Example 3 on rhino methods import rhinoscriptsyntax as rs c1= c2= c3= c4= c5= c6= c7= c8=
rs.AddPoint((0,0,0)) rs.AddPoint((1,0,0)) rs.AddPoint((1,1,0)) rs.AddPoint((0,1,0)) rs.AddPoint((0,0,1)) rs.AddPoint((1,0,1)) rs.AddPoint((1,1,1)) rs.AddPoint((0,1,1))
rs.AddBox([c1,c2,c3,c4,c5,c6,c7,c8])
import rhinoscriptsyntax as rs c1= c2= c3= c4= c5= c6= c7= c8=
rs.AddPoint((0,0,0)) rs.AddPoint((1,-0.5,0.5)) rs.AddPoint((3,1,0)) rs.AddPoint((0,1,0)) rs.AddPoint((0,0,1)) rs.AddPoint((1,0,1)) rs.AddPoint((1,1,1)) rs.AddPoint((0,1,0.2))
rs.AddTextDot("P1",c1) rs.AddTextDot("P2",c2) rs.AddTextDot("P3",c3) rs.AddTextDot("P4",c4) rs.AddTextDot("P5",c5) rs.AddTextDot("P6",c6) rs.AddTextDot("P7",c7) rs.AddTextDot("P8",c8) rs.AddBox([c1,c2,c3,c4,c5,c6,c7,c8])
Do you think is it possible to combine the Add box method with for_loop Iterator and if it makes sense add some conditionals to sort a 2D or 3D arrays of twisted boxes?
Example 4 Nested Loops, import types import import import # From
math Rhino as R rhinoscriptsyntax as rs math import *
pi = math.pi
rs.EnableRedraw(False) for i in rs.frange(0,10*pi,0.2): for j in rs.frange(0,4*pi,0.2): x =j y = i*math.fabs(math.sin(j)) z = math.cos(i) #rs.AddPoints ((j,i*math.fabs(math.sin(j)),math.cos(i))) rs.AddSphere((x,y,z),0.1) rs.EnableRedraw(True)
Example 4 While loop or conditional loop, Function,â&#x20AC;Ś Can you think of a script that with conditional-loop structure transform the design entities in your model to the desired input volumes with specific properties? import rhinoscriptsyntax as rs # Iteratively scale down a curve until it becomes shorter than a certain length start = 0 stop = 200 step = 20 def fitcurvetolength(): curve_id = rs.GetObject("Select a curve to fit to length", rs.filter.curve, True, True) if curve_id is None: return length = rs.CurveLength(curve_id) length_limit = rs.GetReal("Length limit", 0.5 * length, 0.01 * length, length) if length_limit is None: return while True: if rs.CurveLength(curve_id)<=length_limit: break for i in rs.frange(start,stop,step): curve_id = rs.ScaleObject(curve_id,(rs.CurveAreaCentroid(curve_id))[0] , (0.95, 0.95, 0.95),True) rs.MoveObject(curve_id,(0,0,i)) rs.AddGroup("scaled") rs.AddObjectToGroup(curve_id,"scaled") rs.MoveObject(curve_id,(0,0,i)) #rs.RotateObject(curve_id,(rs.CurveAreaCentroid(curve_id))[0],i,None,True ) #rs.AddPoint((rs.CurveAreaCentroid(curve_id))[0]) #rs.TransformObject() if curve_id is None: print "Something went wrong..." return print "New curve length: ", rs.CurveLength(curve_id)
if __name__=="__main__": fitcurvetolength()
Itâ&#x20AC;&#x2122;s simple! However, we need more practice If we want to implement them in real cases And for our own projects So try with more examples for Lists Dictionaries Conditionals Loops Etc.
RECURSION AND ITERATION
Example 5: 2D tree structure import rhinoscriptsyntax as rs import random import scriptcontext def drawbranch(x,line): scriptcontext.escape_test() if x==0: return else: for i in range (0,20): endpt = rs.CurveEndPoint(line) srtpt=rs.CurveStartPoint(line) vect = rs.VectorCreate(endpt, srtpt) rnd=random.randint(-30,30) vect = rs.VectorRotate(vect,rnd,[0,0,1]) ptadd=rs.PointAdd(endpt,vect) line=rs.AddLine(endpt,ptadd) drawbranch(x-1,line) line=rs.AddLine([0,0,0],[10,0,0]) drawbranch(3,line)
Example 5: with comments or pseudo code import rhinoscriptsyntax as rs import random import scriptcontext #define a fuction called drawbranch #### inside the function#### #have a line so i can use 'escape'key #get a start and end point of a starting curve #make a vector between the start point and end point #get a random integer which will be a degree to rotate the curve to make the branching #add points after rotation and add line to make a new branch #call the function called drawbrach again to make it a recursion ####end of the function#### #note: points and vectors are interchangable #make a initial starting line for an input #call the function def drawbranch(x,line): scriptcontext.escape_test() if x==0: return else: for i in range (0, 10): endpt=rs.CurveEndPoint(line) srtpt=rs.CurveStartPoint(line) vect=rs.VectorCreate(endpt,srtpt) rnd=random.randint(-30,30) rand1=random.randint(-5,5) rand2=random.randint(-5,5) vect=rs.VectorRotate(vect,rnd,[rand1,rand2,0]) ptadd=rs.PointAdd(endpt,vect) line=rs.AddLine(endpt,ptadd) drawbranch(x-1,line) line=rs.AddLine([0,0,0],[0,0,10]) drawbranch(3,line)
Then how you can pick the last free ended lines and draw the cover of the umbrella orâ&#x20AC;Ś?
Example 5: 3D tree structure import rhinoscriptsyntax as rs import random import scriptcontext def drawbranch(x,line): scriptcontext.escape_test() if x==0: return else: for i in range (0, 2): endpt=rs.CurveEndPoint(line) srtpt=rs.CurveStartPoint(line) vect=rs.VectorCreate(endpt,srtpt) rand=random.randint(-30,30) rand1=random.randint(-5,5) rand2=random.randint(-5,5) vect=rs.VectorRotate(vect,rand,[rand1,rand2,0]) ptadd=rs.PointAdd(endpt,vect) line=rs.AddLine(endpt,ptadd) drawbranch(x-1,line) line=rs.AddLine([0,0,0],[0,0,10]) drawbranch(10,line)
Can you set the number of the iteration and the domains for branching Etc. interactively In rhino command line
REFERENCES
Some of the references : Links: http://docs.python.org http://wiki.mcneel.com/developer http://python.rhino3d.com/forums/ http://docs.python.org http://www.grasshopper3d.com/group/rhinopython … Books Think Python, by Allen B Downey PYTHON 101 PRIMER , by Skylar Tibbits Beginning Python Book, by by magnus lie hetland IronPython in Action Book, by Michael Foord and Christian Muirhead Python Essential References Book by david m beazley BIM handbook by EASTMAN, C., TEICHOLZ, P., SACKS, R. & LISTON, K. Perforamtive Architecture, Beyond Instrumentality by Kolarevic, B. & Malkawi,(2005) A.M., … Essays Oxman, R. (2009), Performative Design, a performance-model of digital architectural design Aish, R. (2005), From Intuition to Precision, Digital Design: The Quest for New Paradigms 23rd eCAADe,Conference, Lisbon (Portugal) …
THE END OF THE DAY 1
DESIGN TIME QUESTIONS AND ANSWERS GROUP BRAINSTORMING SESSION