## Final Work: Caroline Redelmeier M.Arch                 ## ArrangeHousing_(genRandom)

```import rhinoscriptsyntax as rs
import random

def ArrangeHousing():
"""Locates and Generates units from existing curves"""

curveList = rs.GetObjects()
x = 0.05
for curve in curveList:
number = random.random()
if number > 0.8:
trans = [0,0,9]
midCurve = rs.CopyObject(curve, trans)
centroid = rs.CurveAreaCentroid(curve)
origin = centroid
scale = [x,x,1]
topCurve = rs.ScaleObject(curve, origin, scale, True)
trans2 = [0,0,25 *number]
rs.MoveObject(topCurve, trans2)
ids = [curve, midCurve, topCurve]
rs.OffsetSurface(house, 5)
x = x + 0.01
ArrangeHousing()
``` ## 许文

import rhinoscriptsyntax as rs
import math as mt
def lisacurve():
nlist= range(1 , 8)
for n in nlist:
anglelist = range( 0, 360)
crvList = []
ptlist = []
for angle in anglelist:
a = 1
b = 1
c = 1
x = a * mt.sin(n * t + c)
y = b * mt.sin(t)
ptposition = (x, y, mt.sin(angle))
ptlist.append(pt)
lisacurve()

## March 27 Loops

```
import rhinoscriptsyntax as rs

"""LOOPS"""

def forLOOP():
# USING XRANGE
evens = [2,4,6,8]
for even in evens:
print even
for x in xrange(8):
print x
for x in xrange(3,6):
print x

forLOOP()

"""while loops have boolean condition"""

def whileLOOP():
count = 0
while count < 10:
print count
count += 1
if count >= 5:
break
"""limts the outcome between 0-4"""

whileLOOP()

```
Posted in Announcements | Tagged , | 1 Comment

## March 26 Generators

```def fib():
a, b = 2, 3
while 1:
yield a
a, b = b, a + b

import types
if type ( fib()) == types.GeneratorType:
print "fib series."

counter = 0
for n in fib():
print n
counter += 1
if counter == 15:
break

```

## March 25 Learning Strings Codes

```
import rhinoscriptsyntax as rs

def ArithmeticOperators ():
number = 1 + 2 * 3 /2.0
print number
remainder = 13 % 3
print remainder
squared = 5 ** 2
print squared
cubed = 2 ** 3
print cubed

ArithmeticOperators ()

def LearnStrings():
hello = "hello"
print hello
manyhello = "hello" * 13
print manyhello

Astring = "Hey Man."

print len(Astring)
"""len(x) prints out the number of
characters including punctuation"""

print Astring.index("y")
""" y is the second character """

print Astring.count("a")
""" there is only one a character """

LearnStrings()

```

## code16

```</pre>
import rhinoscriptsyntax as rs

def triangle():
p0 = [0,0,0]
p1 = [0.25,0.75,0]
p2 = [0,1,0]
pts = [p0,p1,p2,p0]
return tri

def rotate(obj,angle):
center = [0,0,0]
result = rs.RotateObject(obj,center,angle)
return result

def cyclic(number):
increment = 360/number
angle = 0
count = range(number)
for i in count:
tri = triangle()
tri = rotate(tri,angle)
angle = angle + increment

cyclic(10)
<pre>```

Posted in Assignments | 1 Comment

## code15

```</pre>
import rhinoscriptsyntax as rs

def triangle():
p0 = [0,0,0]
p1 = [0.25,0.75,0]
p2 = [0,1,0]
pts = [p0,p1,p2,p0]
return tri

def translate(obj,x,y):
translation = [x,y,0]
trans = rs.MoveObject(obj,translation)
return trans

def reflect_y(obj):
start = [0,-1,0]
end = [0,1,0]
ref = rs.MirrorObject(obj,start,end)
return ref

def rotate(obj,angle):
center = [0,0,0]
result = rs.RotateObject(obj,center,angle)
return result

def square_grid(spacing,h_number,v_number):
ty = 0
v_count = range(v_number)
h_count = range(h_number)
for v in v_count:
tx = 0
for h in h_count:
tri = triangle()
tri = translate(tri,tx,ty)
tx = tx + spacing
ty = ty + spacing

square_grid(1.2,4,4)
<pre>```

## code14

```</pre>
import rhinoscriptsyntax as rs

def triangle():
p0 = [0,0,0]
p1 = [0.25,0.75,0]
p2 = [0,1,0]
pts = [p0,p1,p2,p0]
return tri

def translate(obj,x,y):
translation = [x,y,0]
trans = rs.MoveObject(obj,translation)
return trans

def simpleFrieze(spacing,number):
tx = 0
count = range(number)
for i in count:
tri = triangle()
tri = translate(tri,tx,0)
tx = tx + spacing

simpleFrieze(1,6)
<pre>```

## code13

```</pre>
import rhinoscriptsyntax as rs

def triangle():
p0 = [0,0,0]
p1 = [0.25,0.75,0]
p2 = [0,1,0]
pts =[p0,p1,p2,p0]
return tri

def translate(obj,x,y):
translation = [x,y,0]
trans = rs.MoveObject(obj,translation)
return trans

def reflect_y(obj):
start = [0,-1,0]
end = [0,1,0]
ref = rs.MirrorObject(obj,start,end)
return ref

def rotate(obj,angle):
center = [0,0,0]
result = rs.RotateObject(obj,center,angle)
return result

def frieze(x_separation,y_separation,spacing, number):
tx = 0
count = range(number)
for i in count:
tri = triangle()
tri = reflect_y(tri)
tri = rotate(tri,180)
tx = tx + x_separation
ty = -y_separation
tri = translate(tri,tx,ty)
tri = triangle()
tri = translate(tri,tx,0)
tx = tx + spacing

frieze(1,1,0.5,6)
<pre>```