Thursday, August 27, 2009

Booleans with solids


import py2rhino as p2r
print p2r._version

#------------------------------------------------------------------------------
floor_height = 3

#------------------------------------------------------------------------------
def create_box(floor_num):
z1 = floor_height * floor_num
z2 = z1 + 0.5

p1 = (0,0,z1)
p2 = (30,0,z1)
p3 = (30,30,z1)
p4 = (0,30,z1)

p5 = (0,0,z2)
p6 = (30,0,z2)
p7 = (30,30,z2)
p8 = (0,30,z2)

corner_points = (p1,p2,p3,p4,p5,p6,p7,p8)
return p2r.obj.Box.create(corner_points)
#------------------------------------------------------------------------------
sph = p2r.obj.Sphere.create((15,15,15), 12)

boxes = []
for floor_num in range(10):
box = create_box(floor_num)
box = sph.func.boolean_intersection(box, False)
boxes.append(box)
sph = p2r.obj.Sphere.create((0,0,0), 5)

print sph.func.boolean_difference( box )

No comments:

Post a Comment