Expand/Explain examples for mixed mode (Builder and Algebra mode)
Opened this issue · 1 comments
CePeU commented
Builder Mode - WORKS
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex2:
Box(length, width, thickness)
Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
Algebra Mode - WORKS
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
ex2 = Box(length, width, thickness)
ex2 -= Cylinder(center_hole_dia / 2, height=thickness)
MIXED MODE - FAILS
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0
with BuildPart() as ex1:
Box(length, width, thickness)
with BuildPart() as ex2:
Cylinder(radius=center_hole_dia / 2, height=thickness)
ex3=ex1-ex2
show_object(ex3)
Explain that you need to use PART
ex3=ex1.part-ex2.part
show_object(ex3)
gumyr commented
To help address this issue commit 3389545 introduces new error messages to help guide new users:
with BuildPart() as a:
Box(1, 1, 1)
with BuildPart() as b:
Cylinder(1, 1)
c = a + b
RuntimeError: BuildPart is a builder of Shapes and can't be combined. The object being constructed is accessible via the 'part' attribute.
(the same error message applies to '-' and &
operators).
Invalid method calls are also handled as shown here:
with BuildSketch() as a:
Rectangle(1, 1)
a.export_stl("broken.stl")
AttributeError: 'BuildSketch' has no attribute 'export_stl'. Did you intend '<BuildSketch>.sketch.export_stl'?