-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcadquery.py
More file actions
27 lines (21 loc) · 1.19 KB
/
cadquery.py
File metadata and controls
27 lines (21 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cadquery as cq
from jupyter_cadquery import show as jupyter_show
from ipywidgets import interact
def create_building(levels, floor_thickness, floor_area, window_size, floor_height):
building_length = floor_area**0.5
building_width = floor_area**0.5
building_height = levels * floor_height
building = cq.Workplane("XY").box(building_length, building_width, building_height)
for level in range(levels):
window_start_height = level * floor_height + floor_thickness
window_end_height = window_start_height + window_size
building = building.faces(">Z").workplane(offset=window_start_height).rect(building_length - 2*floor_thickness, window_size).cutThruAll()
return building
# Example usage
building = create_building(5, 0.3, 100, 2, 3)
jupyter_show(building)
# Define the interactive function with @interact decorator
@interact(levels=(1, 10), floor_thickness=(0.1, 1.0), floor_area=(10, 1000), window_size=(0.1, 5.0), floor_height=(1, 10))
def update_building(levels, floor_thickness, floor_area, window_size, floor_height):
building = create_building(levels, floor_thickness, floor_area, window_size, floor_height)
jupyter_show(building)