Skip to content

Instantly share code, notes, and snippets.

@medicationforall
Last active November 7, 2022 14:13
Show Gist options
  • Save medicationforall/cd9a26215ba9f725b4e6e64b34b90044 to your computer and use it in GitHub Desktop.
Save medicationforall/cd9a26215ba9f725b4e6e64b34b90044 to your computer and use it in GitHub Desktop.
import cadquery as cq
from cqterrain import Building, stone, window
def add_stones(wall, length, height, wall_width, rotate=0, seed="test4"):
# static boxes to act as stone
tile = cq.Workplane("XY").box(10,10,2)
tile2 = cq.Workplane("XY").box(8,8,2)
tile3 = cq.Workplane("XY").box(6,12,2)
tile4 = cq.Workplane("XY").cylinder(6,4)
# create an array of the stones and chamfer / fillet to add interest to the shapes.
stone_list = [tile.chamfer(0.8), tile2.fillet(.5), tile3.chamfer(0.5), tile4]
# This is the pattern generator
stones = stone.make_stones(stone_list, [12,12,2], columns = 14, rows = 3, seed=seed).rotate((0,1,0),(0,0,0), 90).rotate((0,0,1),(0,0,0), 90)
# Align the pattern and surround with a frame
stones = stones.translate((0,-2,-1*(height/2)+(24))).rotate((0,0,1),(0,0,0), rotate)
frame = window.frame(length, 2, 48).translate((0,-1*((1)+(wall_width/2)),-1*(height/2)+(24))).rotate((0,0,1),(0,0,0), rotate)
# Add the detailing to the room wall
return wall.add(stones).add(frame)
def make_arch_door(wall, length, width, height, floor_height):
# find the bottom of the wall to align to.
bottom = wall.faces("-Z").val()
#create the initial shape
cutout = (cq.Workplane(bottom.Center())
.box(length, width, height)
.translate((0,0,(height/2)+floor_height))
)
# round off the top
cutout = cutout.faces("Z").edges("Y").fillet((length/2)-.5)
#remove the arch from the wall
w = wall.cut(cutout)
return w
bp = Building(length=175, width=175, height=350, stories=2)
bp.room['build_walls']= [False,True,True,True]
bp.room['window_walls'] = [False, True, True, False]
bp.room['door_walls'] = [False, False, True, True]
bp.room['make_custom_door'] = make_arch_door
bp.door['length'] = 80
bp.door['height'] = 100
bp.make()
first_floor = bp.floors[0]
first_floor.window_walls = [False, False, False, False]
first_floor.make()
st_front_wall = bp.floors[0].walls[1]
stone_wall = add_stones(st_front_wall, 175, bp.floors[0].height, bp.floors[0].wall_width)
bp.floors[0].walls[1] = stone_wall
st_front_wall = bp.floors[1].walls[1]
stone_wall = add_stones(st_front_wall, 175, bp.floors[1].height, bp.floors[1].wall_width, seed="demo")
bp.floors[1].walls[1] = stone_wall
build = bp.build()
show_object(build)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment