from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinder from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Fuse from OCC.Core.STEPControl import STEPControl_Writer, STEPControl_AsIs from OCC.Core.STLAPI import STLAPI_Writer from OCC.Core.TopoDS import TopoDS_Compound from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_Transform from OCC.Core.gp import gp_Trsf, gp_Vec
def fuse_shapes(shapes): result = shapes[0] for shape in shapes[1:]: result = BRepAlgoAPI_Fuse(result, shape).Shape() return result
chassis = BRepPrimAPI_MakeBox(100, 30, 15).Shape()
wheel_front_left = BRepPrimAPI_MakeCylinder(10, 5).Shape() wheel_front_right = BRepPrimAPI_MakeCylinder(10, 5).Shape() wheel_rear_left = BRepPrimAPI_MakeCylinder(10, 5).Shape() wheel_rear_right = BRepPrimAPI_MakeCylinder(10, 5).Shape()
trsf_fl = gp_Trsf() trsf_fl.SetTranslation(gp_Vec(15, -10, -2)) wheel_front_left = BRepBuilderAPI_Transform(wheel_front_left, trsf_fl).Shape()
trsf_fr = gp_Trsf() trsf_fr.SetTranslation(gp_Vec(15, 40, -2)) wheel_front_right = BRepBuilderAPI_Transform(wheel_front_right, trsf_fr).Shape()
trsf_rl = gp_Trsf() trsf_rl.SetTranslation(gp_Vec(85, -10, -2)) wheel_rear_left = BRepBuilderAPI_Transform(wheel_rear_left, trsf_rl).Shape()
trsf_rr = gp_Trsf() trsf_rr.SetTranslation(gp_Vec(85, 40, -2)) wheel_rear_right = BRepBuilderAPI_Transform(wheel_rear_right, trsf_rr).Shape()
front_wing = BRepPrimAPI_MakeBox(40, 10, 3).Shape() trsf_fw = gp_Trsf() trsf_fw.SetTranslation(gp_Vec(10, 10, 12)) front_wing = BRepBuilderAPI_Transform(front_wing, trsf_fw).Shape()
rear_wing = BRepPrimAPI_MakeBox(50, 10, 5).Shape() trsf_rw = gp_Trsf() trsf_rw.SetTranslation(gp_Vec(80, 10, 15)) rear_wing = BRepBuilderAPI_Transform(rear_wing, trsf_rw).Shape()
support_front = BRepPrimAPI_MakeBox(5, 5, 10).Shape() trsf_sf = gp_Trsf() trsf_sf.SetTranslation(gp_Vec(28, 13, 2)) support_front = BRepBuilderAPI_Transform(support_front, trsf_sf).Shape()
support_rear = BRepPrimAPI_MakeBox(5, 5, 10).Shape() trsf_sr = gp_Trsf() trsf_sr.SetTranslation(gp_Vec(100, 13, 5)) support_rear = BRepBuilderAPI_Transform(support_rear, trsf_sr).Shape()
all_parts = [chassis, wheel_front_left, wheel_front_right, wheel_rear_left, wheel_rear_right, front_wing, rear_wing, support_front, support_rear]
f1_car = fuse_shapes(all_parts)
stl_writer = STLAPI_Writer() stl_writer.Write(f1_car, "f1_auto_met_supports.stl")
print("STL-bestand 'f1_auto_met_supports.stl' is succesvol aangemaakt!")