Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various Documentation Fixes #737

Merged
merged 7 commits into from
Oct 22, 2024
2 changes: 1 addition & 1 deletion docs/introductory_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ They are organized from simple to complex, so working through them in order is t
1. ``from build123d import *``
2. If you are using build123d *builder mode* or *algebra mode*,

- in *ocp_vscode* simply use e.g. ``show(ex15)`` to the end of your design to view parts, sketches and curves. `show_all()` can be used to automatically show all objects with their variable names as labels.
- in *ocp_vscode* simply use e.g. ``show(ex15)`` to the end of your design to view parts, sketches and curves. ``show_all()`` can be used to automatically show all objects with their variable names as labels.
- in *CQ-editor* add e.g. ``show_object(ex15.part)``, ``show_object(ex15.sketch)`` or ``show_object(ex15.line)`` to the end of your design to view parts, sketches or lines.

3. If you want to save your resulting object as an STL from *builder mode*, you can use e.g. ``export_stl(ex15.part, "file.stl")``.
Expand Down
15 changes: 4 additions & 11 deletions examples/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,10 @@
tangents=((0, 0, 1), (0, 0, -1)),
tangent_scalars=(1.5, 1.5),
)
# Record the center line for display and workplane creation
handle_path: Wire = handle_center_line.wires()[0]

# Create the cross sections - added to pending_faces
for i in range(segment_count + 1):
with BuildSketch(
Plane(
origin=handle_path @ (i / segment_count),
z_dir=handle_path % (i / segment_count),
)
) as section:
with BuildSketch(handle_center_line.line ^ (i / segment_count)) as section:
if i % segment_count == 0:
Circle(1)
else:
Expand All @@ -66,8 +59,8 @@

assert abs(handle.part.volume - 94.77361455046953) < 1e-3

show_object(handle_path.wrapped, name="handle_path")
show_object(handle_center_line.line, name="handle_center_line")
for i, section in enumerate(sections):
show_object(section.wrapped, name="section" + str(i))
show_object(handle.part.wrapped, name="handle", options=dict(alpha=0.6))
show_object(section, name="section" + str(i))
show_object(handle.part, name="handle", options=dict(alpha=0.6))
# [End]
19 changes: 6 additions & 13 deletions examples/handle_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,23 @@
tangents=((0, 0, 1), (0, 0, -1)),
tangent_scalars=(1.5, 1.5),
)
# Record the center line for display and workplane creation
handle_path = handle_center_line.edges()[0]


# Create the cross sections - added to pending_faces

sections = Sketch()
for i in range(segment_count + 1):
plane = Plane(
origin=handle_path @ (i / segment_count),
z_dir=handle_path % (i / segment_count),
)
location = handle_center_line ^ (i / segment_count)
if i % segment_count == 0:
circle = plane * Circle(1)
circle = location * Circle(1)
else:
circle = plane * Rectangle(1.25, 3)
circle = location * Rectangle(1.25, 3)
circle = fillet(circle.vertices(), radius=0.2)
sections += circle

# Create the handle by sweeping along the path
handle = sweep(sections, path=handle_path, multisection=True)
handle = sweep(sections, path=handle_center_line, multisection=True)

show_object(handle_path.wrapped, name="handle_path")
show_object(handle_center_line, name="handle_path")
for i, circle in enumerate(sections):
show_object(circle.wrapped, name="section" + str(i))
show_object(circle, name="section" + str(i))
show_object(handle, name="handle", options=dict(alpha=0.6))
# [End]
8 changes: 3 additions & 5 deletions examples/tea_cup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,22 @@

# Determine where the handle contacts the bowl
handle_intersections = [
tea_cup.part.find_intersection(
tea_cup.part.find_intersection_points(
Axis(origin=(0, 0, vertical_offset), direction=(1, 0, 0))
)[-1][0]
for vertical_offset in [35 * MM, 80 * MM]
]
# Create a path for handle creation
with BuildLine(Plane.XZ) as handle_path:
path_spline = Spline(
Spline(
handle_intersections[0] - (wall_thickness / 2, 0),
handle_intersections[0] + (35 * MM, 30 * MM),
handle_intersections[0] + (40 * MM, 60 * MM),
handle_intersections[1] - (wall_thickness / 2, 0),
tangents=((1, 1.25), (-0.2, -1)),
)
# Align the cross section to the beginning of the path
with BuildSketch(
Plane(origin=path_spline @ 0, z_dir=path_spline % 0)
) as handle_cross_section:
with BuildSketch(handle_path.line ^ 0) as handle_cross_section:
RectangleRounded(wall_thickness, 8 * MM, fillet_radius)
sweep() # Sweep handle cross section along path

Expand Down
6 changes: 3 additions & 3 deletions examples/tea_cup_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# Determine where the handle contacts the bowl
handle_intersections = [
tea_cup.find_intersection(
tea_cup.find_intersection_points(
Axis(origin=(0, 0, vertical_offset), direction=(1, 0, 0))
)[-1][0]
for vertical_offset in [35 * MM, 80 * MM]
Expand All @@ -49,8 +49,8 @@
)

# Align the cross section to the beginning of the path
plane = Plane(origin=path_spline @ 0, z_dir=path_spline % 0)
handle_cross_section = plane * RectangleRounded(wall_thickness, 8 * MM, fillet_radius)
location = path_spline ^ 0
handle_cross_section = location * RectangleRounded(wall_thickness, 8 * MM, fillet_radius)

# Sweep handle cross section along path
tea_cup += sweep(handle_cross_section, path=path_spline)
Expand Down