Skip to content

Commit c933a2c

Browse files
committed
Create box.py
1 parent c679364 commit c933a2c

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/pythonocc/example/box.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from OCC.Display.SimpleGui import init_display
2+
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
3+
4+
5+
def create_box(width, height, depth):
6+
"""
7+
Function to create a 3D box.
8+
9+
Args:
10+
width (float): Width of the box.
11+
height (float): Height of the box.
12+
depth (float): Depth of the box.
13+
14+
Returns:
15+
TopoDS_Shape: The TopoDS shape of the box.
16+
"""
17+
# Create a box
18+
box = BRepPrimAPI_MakeBox(width, height, depth).Shape()
19+
return box
20+
21+
22+
def main():
23+
# Initialize the display
24+
display, start_display, add_menu, add_function_to_menu = init_display()
25+
26+
# Create a box with dimensions 10x20x30
27+
my_box = create_box(10.0, 20.0, 30.0)
28+
29+
# Display the box
30+
display.DisplayShape(my_box, update=True)
31+
32+
# Start the GUI loop
33+
start_display()
34+
35+
36+
if __name__ == "__main__":
37+
main()

0 commit comments

Comments
 (0)