Skip to content

Instantly share code, notes, and snippets.

@captDaylight captDaylight/rhino_test.py
Last active Dec 11, 2018

Embed
What would you like to do?
import random
import rhinoscriptsyntax as rs
def draw_box(x, y, z, box_size):
surface_points = [
[x, y, z],
[x + box_size, y, z],
[x + box_size, y + box_size, z],
[x, y + box_size, z]
]
curve = rs.AddCurve([x, y, z], [x, y, z + box_size])
surface = rs.AddSrfPts(surface_points)
box = rs.ExtrudeSurface(surface, curve)
rs.DeleteObjects([curve, surface])
return box
def draw_unit(x, y):
box_size = 0.1
probabilty = 1
pos = [0, 0, 0]
boxes = []
boxes.append(draw_box(x, y, 0))
while random.random() < probabilty:
probabilty += 0.1
ran = random.random()
if ran < 0.333:
pos[0] += box_size
elif ran < 0.666:
pos[1] += box_size
else:
pos[2] += box_size
boxes.append(draw_box(x + pos[0], y + pos[1], 0 + pos[2], box_size))
rs.BooleanUnion(boxes)
def main():
for x in range(5):
for y in range(5):
draw_unit(x, y)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.