Add build configurations for ttts, examples, general_examples, partial topo selection

This commit is contained in:
Jonathan Wagenet 2026-01-15 16:35:23 -05:00
parent 5c0046bf37
commit fb5d9606d6
15 changed files with 406 additions and 232 deletions

View file

@ -0,0 +1,31 @@
{
"sources": [
"../examples"
],
"build": [
"save_examples"
],
"thumbnails": [
{ "source": "benchy.png" },
{ "source": "bicycle_tire_detail.png", "label": "bicycle_tire", "push": "bottom" },
{ "source": "bracelet.png" },
{ "source": "build123d_logo.png" },
{ "source": "canadian_flag.png" },
{ "source": "cast_bearing_unit.png" },
{ "source": "circuit_board.png" },
{ "source": "clock_face.png" },
{ "source": "fast_grid_holes.png" },
{ "source": "handle.png" },
{ "source": "heat_exchanger_detail.png", "label": "heat_exchanger" },
{ "source": "key_cap.png" },
{ "source": "loft.png" },
{ "source": "maker_coin.png" },
{ "source": "peg_board_hook.png" },
{ "source": "platonic_solids.png" },
{ "source": "playing_cards.png" },
{ "source": "stud_wall.png" },
{ "source": "tea_cup.png" },
{ "source": "toy_truck.png" },
{ "source": "vase.png" }
]
}

View file

@ -0,0 +1,61 @@
from tcv_screenshots import save_model
from build123d import Color, Compound, Rot, Pos
import benchy
import bicycle_tire
import bracelet
import build123d_logo
import canadian_flag
import cast_bearing_unit
import circuit_board
import clock
import fast_grid_holes
import handle
import heat_exchanger
import key_cap
import loft
import maker_coin
import pegboard_j_hook
import platonic_solids
import playing_cards
import stud_wall
import tea_cup
import toy_truck
import vase
save_model([benchy.benchy], "benchy")
save_model([benchy.benchy], "benchy_front", {"reset_camera": "front"})
save_model([benchy.benchy], "benchy_right", {"reset_camera": "right"})
save_model([bicycle_tire.tire, bicycle_tire.tread], "bicycle_tire", {"cadWidth": 2000, "height": 2000})
size = bicycle_tire.tire.bounding_box().size.Y
tire_config = {"zoom": 4, "position": (size / 2, -size, size), "target": (0, -size / 2, size / 2),}
save_model([bicycle_tire.tire, bicycle_tire.tread], "bicycle_tire_detail", tire_config)
save_model([Rot(Z=-90) * bracelet.bracelet], "bracelet")
save_model([build123d_logo.one, build123d_logo.two, build123d_logo.three_d, build123d_logo.extension_lines, build123d_logo.build], "build123d_logo")
save_model([Rot(Z=-45) * Rot(90) * canadian_flag.canadian_flag], "canadian_flag", {"reset_camera": "front", "ortho": False})
save_model([canadian_flag.canadian_flag], "canadian_flag_iso", {"ortho": False})
save_model([Rot(30, 0, 30) * canadian_flag.canadian_flag], "canadian_flag_detail", {"reset_camera": "front", "ortho": False})
save_model([cast_bearing_unit.oval_flanged_bearing_unit], "cast_bearing_unit", {"render_edges": False})
save_model([circuit_board.pcb], "circuit_board")
save_model([circuit_board.pcb], "circuit_board_top", {"reset_camera": "top"})
save_model([clock.clock_face], "clock_face", {"reset_camera": "top"})
save_model([fast_grid_holes.grid], "fast_grid_holes")
handle.handle.color = Color("goldenrod", .6)
save_model([handle.handle, handle.handle_center_line, handle.sections], "handle")
save_model([heat_exchanger.heat_exchanger], "heat_exchanger" , {"cadWidth": 2000, "height": 2000})
size = heat_exchanger.heat_exchanger.part.bounding_box().size.Z
exchanger_config = {"zoom": 2, "position": (size / 2, -size, size), "target": (0, 0, size / 2)}
save_model([heat_exchanger.heat_exchanger], "heat_exchanger_detail", exchanger_config)
key_cap.key_cap.color = Color("goldenrod", .3)
save_model([key_cap.key_cap], "key_cap")
save_model([loft.art], "loft")
save_model([maker_coin.maker_coin], "maker_coin")
save_model([Rot(Y=-90) * pegboard_j_hook.mainp.part], "peg_board_hook")
save_model([Rot(Z=90) * Compound(platonic_solids.solids)], "platonic_solids")
playing_cards.lid_builder.part.color = Color("goldenrod", .7)
save_model([Pos(-20, 40) * playing_cards.hand, playing_cards.box_builder, Pos(0, 0, (playing_cards.wall + playing_cards.deck) / 2) * playing_cards.lid_builder.part], "playing_cards")
save_model([Rot(15, 0, -30) * Compound([stud_wall.x_wall, stud_wall.y_wall])], "stud_wall", {"reset_camera": "front"})
tea_cup.tea_cup.color = "goldenrod"
save_model([tea_cup.tea_cup], "tea_cup")
save_model([Rot(15, 0, -120) * Compound([toy_truck.body.part, toy_truck.cab.part], color=toy_truck.truck_color)], "toy_truck", {"reset_camera": "front", "render_edges": False})
save_model([Rot(90, 0, 0) * vase.vase.part], "vase")

View file

@ -0,0 +1,8 @@
{
"sources": [
"general_examples/examples"
],
"build": [
"general_examples"
]
}

View file

@ -0,0 +1,9 @@
{
"sources": [
"topology_selection/examples"
],
"build": [
"filter_all_edges_circle",
"filter_inner_wire_count"
]
}

View file

@ -0,0 +1,20 @@
{
"build": [
"save_ttts"
],
"thumbnails": [
{ "source": "ttt-ppp0101.png" },
{ "source": "ttt-ppp0102.png" },
{ "source": "ttt-ppp0103.png" },
{ "source": "ttt-ppp0104.png" },
{ "source": "ttt-ppp0105.png" },
{ "source": "ttt-ppp0106.png" },
{ "source": "ttt-ppp0107.png" },
{ "source": "ttt-ppp0108.png" },
{ "source": "ttt-ppp0109.png" },
{ "source": "ttt-ppp0110.png" },
{ "source": "ttt-23-02-02-sm_hanger.png" },
{ "source": "ttt-23-t-24-curved_support.png" },
{ "source": "ttt-24-SPO-06-Buffer_Stand.png" }
]
}

View file

@ -0,0 +1,31 @@
import importlib
from tcv_screenshots import save_model
from build123d import Rot
tttppp0101 = importlib.import_module("ttt-ppp0101")
tttppp0102 = importlib.import_module("ttt-ppp0102")
tttppp0103 = importlib.import_module("ttt-ppp0103")
tttppp0104 = importlib.import_module("ttt-ppp0104")
tttppp0105 = importlib.import_module("ttt-ppp0105")
tttppp0106 = importlib.import_module("ttt-ppp0106")
tttppp0107 = importlib.import_module("ttt-ppp0107")
tttppp0108 = importlib.import_module("ttt-ppp0108")
tttppp0109 = importlib.import_module("ttt-ppp0109")
tttppp0110 = importlib.import_module("ttt-ppp0110")
ttt230202 = importlib.import_module("ttt-23-02-02-sm_hanger")
ttt23t24 = importlib.import_module("ttt-23-t-24-curved_support")
ttt24SPO06 = importlib.import_module("ttt-24-SPO-06-Buffer_Stand")
save_model([tttppp0101.p], "ttt-ppp0101")
save_model([Rot(Z=180) * tttppp0102.p.part], "ttt-ppp0102")
save_model([Rot(Y=90) * tttppp0103.ppp0103.part], "ttt-ppp0103")
save_model([tttppp0104.p], "ttt-ppp0104")
save_model([Rot(Y=-90) * tttppp0105.p.part], "ttt-ppp0105")
save_model([Rot(-90, 0, 180) * tttppp0106.p.part], "ttt-ppp0106")
save_model([tttppp0107.p], "ttt-ppp0107")
save_model([tttppp0108.p], "ttt-ppp0108")
save_model([tttppp0109.ppp109], "ttt-ppp0109")
save_model([tttppp0110.ppp0110], "ttt-ppp0110")
save_model([ttt230202.sm_hanger], "ttt-23-02-02-sm_hanger")
save_model([Rot(Z=-90) * ttt23t24.curved_support.part], "ttt-23-t-24-curved_support")
save_model([ttt24SPO06.p], "ttt-24-SPO-06-Buffer_Stand")

View file

@ -14,7 +14,7 @@ Basic Functionality
The following is a simple BuildPart example:
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 2]
:end-before: [Ex. 2]
@ -31,7 +31,7 @@ a polyhedron with rectangular faces centered on the default ``Plane.XY``.
The second object is a ``Cylinder`` that is subtracted from the box as directed
by the ``mode=Mode.SUBTRACT`` parameter thus creating a hole.
.. image:: assets/general_ex2.svg
.. image:: _build/assets/general_examples/general_ex2.svg
:align: center
*******************

View file

@ -12,8 +12,12 @@
#
import os
import sys
import build123d
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
from build_artifacts import batch_build_artifacts
build123d_path = os.path.dirname(os.path.abspath(os.getcwd()))
source_files_path = os.path.join(build123d_path, "src", "build123d")
sys.path.insert(0, source_files_path)
@ -128,3 +132,16 @@ hoverxref_domains = [
]
html_logo = "assets/build123d_logo/logo.svg"
# -- Setup methods ----------------------------------------------------------
def build_artifacts(app):
if app.builder.name != "html":
return
folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), "assets")
batch_build_artifacts(folder)
def setup(app):
app.connect("builder-inited", build_artifacts)

View file

@ -8,7 +8,7 @@ The build123d Examples
Overview
--------------------------------
In the GitHub repository you will find an `examples folder <https://github.com/42sol-eu/build123d/tree/examples>`_.
In the GitHub repository you will find an `examples folder <https://github.com/gumyr/build123d/tree/dev/examples>`_.
Most of the examples show the builder and algebra modes.
@ -18,117 +18,118 @@ Most of the examples show the builder and algebra modes.
.. grid:: 3
:gutter: 3
.. grid-item-card:: Benchy |Builder|
:img-top: assets/examples/thumbnail_benchy_01.png
:img-top: _build/assets/examples/thumb_benchy.png
:link: examples-benchy
:link-type: ref
.. grid-item-card:: Bicycle Tire |Builder|
:img-top: assets/examples/bicycle_tire.png
:img-top: _build/assets/examples/thumb_bicycle_tire.png
:link: examples-bicycle_tire
:link-type: ref
.. grid-item-card:: Bracelet |Algebra|
:img-top: assets/examples/bracelet.png
:img-top: _build/assets/examples/thumb_bracelet.png
:link: examples-bracelet
:link-type: ref
.. grid-item-card:: Canadian Flag Blowing in The Wind |Builder| |Algebra|
:img-top: assets/examples/example_canadian_flag_01.png
:link: examples-canadian_flag
:link-type: ref
:img-top: _build/assets/examples/thumb_canadian_flag.png
:link: examples-canadian_flag
:link-type: ref
.. grid-item-card:: Cast Bearing Unit |Builder|
:img-top: assets/examples/cast_bearing_unit.png
:link: examples-cast_bearing_unit
:link-type: ref
:img-top: _build/assets/examples/thumb_cast_bearing_unit.png
:link: examples-cast_bearing_unit
:link-type: ref
.. grid-item-card:: Circuit Board With Holes |Builder| |Algebra|
:img-top: assets/examples/thumbnail_circuit_board_01.png
:link: examples-circuit_board
:link-type: ref
:img-top: _build/assets/examples/thumb_circuit_board.png
:link: examples-circuit_board
:link-type: ref
.. grid-item-card:: Clock Face |Builder| |Algebra|
:img-top: assets/examples/clock_face.png
:link: clock_face
:link-type: ref
:img-top: _build/assets/examples/thumb_clock_face.png
:link: clock_face
:link-type: ref
.. grid-item-card:: Fast Grid Holes |Algebra|
:img-top: assets/examples/fast_grid_holes.png
:link: fast_grid_holes
:link-type: ref
:img-top: _build/assets/examples/thumb_fast_grid_holes.png
:link: fast_grid_holes
:link-type: ref
.. grid-item-card:: Handle |Builder| |Algebra|
:img-top: assets/examples/handle.png
:link: handle
:link-type: ref
:img-top: _build/assets/examples/thumb_handle.png
:link: handle
:link-type: ref
.. grid-item-card:: Heat Exchanger |Builder| |Algebra|
:img-top: assets/examples/heat_exchanger.png
:link: heat_exchanger
:link-type: ref
:img-top: _build/assets/examples/thumb_heat_exchanger.png
:link: heat_exchanger
:link-type: ref
.. grid-item-card:: Key Cap |Builder| |Algebra|
:img-top: assets/examples/key_cap.png
:link: key_cap
:link-type: ref
:img-top: _build/assets/examples/thumb_key_cap.png
:link: key_cap
:link-type: ref
.. grid-item-card:: (former) build123d Logo |Builder| |Algebra|
:img-top: assets/examples/thumbnail_build123d_logo_01.png
:link: examples-build123d_logo
:link-type: ref
:img-top: _build/assets/examples/thumb_build123d_logo.png
:link: examples-build123d_logo
:link-type: ref
.. grid-item-card:: Maker Coin |Builder|
:img-top: assets/examples/maker_coin.png
:link: maker_coin
:link-type: ref
:img-top: _build/assets/examples/thumb_maker_coin.png
:link: maker_coin
:link-type: ref
.. grid-item-card:: Multi-Sketch Loft |Builder| |Algebra|
:img-top: assets/examples/loft.png
:link: multi_sketch_loft
:link-type: ref
:img-top: _build/assets/examples/thumb_loft.png
:link: multi_sketch_loft
:link-type: ref
.. grid-item-card:: Peg Board J Hook |Builder| |Algebra|
:img-top: assets/examples/peg_board_hook.png
:link: peg_board_hook
:link-type: ref
:img-top: _build/assets/examples/thumb_peg_board_hook.png
:link: peg_board_hook
:link-type: ref
.. grid-item-card:: Platonic Solids |Algebra|
:img-top: assets/examples/platonic_solids.png
:link: platonic_solids
:link-type: ref
:img-top: _build/assets/examples/thumb_platonic_solids.png
:link: platonic_solids
:link-type: ref
.. grid-item-card:: Playing Cards |Builder|
:img-top: assets/examples/playing_cards.png
:link: playing_cards
:link-type: ref
:img-top: _build/assets/examples/thumb_playing_cards.png
:link: playing_cards
:link-type: ref
.. grid-item-card:: Stud Wall |Algebra|
:img-top: assets/examples/stud_wall.png
:link: stud_wall
:link-type: ref
:img-top: _build/assets/examples/thumb_stud_wall.png
:link: stud_wall
:link-type: ref
.. grid-item-card:: Tea Cup |Builder| |Algebra|
:img-top: assets/examples/tea_cup.png
:link: tea_cup
:link-type: ref
:img-top: _build/assets/examples/thumb_tea_cup.png
:link: tea_cup
:link-type: ref
.. grid-item-card:: Toy Truck |Builder|
:img-top: assets/examples/toy_truck.png
:link: toy_truck
:link-type: ref
:img-top: _build/assets/examples/thumb_toy_truck.png
:link: toy_truck
:link-type: ref
.. grid-item-card:: Vase |Builder| |Algebra|
:img-top: assets/examples/vase.png
:link: vase
:link-type: ref
:img-top: _build/assets/examples/thumb_vase.png
:link: vase
:link-type: ref
.. NOTE 01: insert new example thumbnails above this line
.. TODO: Copy this block to add the example thumbnails here
.. grid-item-card:: name-of-your-example-with-spaces |Builder| |Algebra|
:img-top: assets/examples/thumbnail_{name-of-your-example}_01.{extension}
:img-top: _build/assets/examples/thumbnail_{name-of-your-example}.{extension}
:link: examples-{name-of-your-example}
:link-type: ref
@ -140,14 +141,14 @@ Most of the examples show the builder and algebra modes.
Benchy
------
.. image:: assets/examples/example_benchy_01.png
.. image:: _build/assets/examples/benchy.png
:align: center
The Benchy examples shows how to import a STL model as a `Solid` object with the class `Mesher` and
modify it by replacing chimney with a BREP version.
- Benchy STL model: :download:`low_poly_benchy.stl <../examples/low_poly_benchy.stl>`
- Benchy STL model: :download:`low_poly_benchy.stl <_build/assets/examples/low_poly_benchy.stl>`
.. note
@ -159,11 +160,11 @@ modify it by replacing chimney with a BREP version.
.. dropdown:: Gallery
.. image:: assets/examples/example_benchy_02.png
.. image:: _build/assets/examples/benchy_front.png
:align: center
.. image:: assets/examples/example_benchy_03.png
.. image:: _build/assets/examples/benchy_right.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -179,7 +180,7 @@ modify it by replacing chimney with a BREP version.
Bicycle Tire
--------------------------------
.. image:: assets/examples/bicycle_tire.png
.. image:: _build/assets/examples/bicycle_tire.png
:align: center
This example demonstrates how to model a realistic bicycle tire with a
@ -199,7 +200,7 @@ surface.
Bracelet
--------------------------------
.. image:: assets/examples/bracelet.png
.. image:: _build/assets/examples/bracelet.png
:align: center
Doubly-curved bracelet with an embossed label
@ -231,7 +232,7 @@ Key techniques demonstrated:
Former build123d Logo
--------------------------------
.. image:: assets/examples/example_build123d_logo_01.png
.. image:: _build/assets/examples/build123d_logo.png
:align: center
@ -260,7 +261,7 @@ The builder mode example also generates the SVG file `logo.svg`.
Cast Bearing Unit
-----------------
.. image:: assets/examples/cast_bearing_unit.png
.. image:: _build/assets/examples/cast_bearing_unit.png
:align: center
This example demonstrates the creation of a castable flanged bearing housing
@ -278,7 +279,7 @@ using the `draft` operation to add appropriate draft angles for mold release.
Canadian Flag Blowing in The Wind
----------------------------------
.. image:: assets/examples/example_canadian_flag_01.png
.. image:: _build/assets/examples/canadian_flag.png
:align: center
@ -290,10 +291,10 @@ This example also demonstrates building complex lines that snap to existing feat
.. dropdown:: More Images
.. image:: assets/examples/example_canadian_flag_02.png
.. image:: _build/assets/examples/canadian_flag_iso.png
:align: center
.. image:: assets/examples/example_canadian_flag_03.png
.. image:: _build/assets/examples/canadian_flag_detail.png
:align: center
@ -317,7 +318,7 @@ This example also demonstrates building complex lines that snap to existing feat
Circuit Board With Holes
------------------------
.. image:: assets/examples/example_circuit_board_01.png
.. image:: _build/assets/examples/circuit_board.png
:align: center
@ -331,7 +332,7 @@ This example demonstrates placing holes around a part.
.. dropdown:: More Images
.. image:: assets/examples/example_circuit_board_02.png
.. image:: _build/assets/examples/circuit_board_top.png
:align: center
@ -354,7 +355,7 @@ This example demonstrates placing holes around a part.
Clock Face
----------
.. image:: assets/examples/clock_face.png
.. image:: _build/assets/examples/clock_face.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -383,7 +384,7 @@ a detailed and visually appealing clock design.
Fast Grid Holes
---------------
.. image:: assets/examples/fast_grid_holes.png
.. image:: _build/assets/examples/fast_grid_holes.png
:align: center
.. dropdown:: |Algebra| Reference Implementation (Algebra Mode)
@ -411,7 +412,7 @@ compared to substantially longer runtimes for boolean subtraction of individual
Handle
------
.. image:: assets/examples/handle.png
.. image:: _build/assets/examples/handle.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -434,7 +435,7 @@ This example demonstrates multisection sweep creating a drawer handle.
Heat Exchanger
--------------
.. image:: assets/examples/heat_exchanger.png
.. image:: _build/assets/examples/heat_exchanger.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -460,7 +461,7 @@ to the end plates to simulate welding.
Key Cap
-------
.. image:: assets/examples/key_cap.png
.. image:: _build/assets/examples/key_cap.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -484,7 +485,7 @@ extrude with a taper and extrude until next.
Maker Coin
----------
.. image:: assets/examples/maker_coin.png
.. image:: _build/assets/examples/maker_coin.png
:align: center
This example creates the maker coin as defined by Angus on the Maker's Muse
@ -510,7 +511,7 @@ YouTube channel. There are two key features:
Multi-Sketch Loft
-----------------
.. image:: assets/examples/loft.png
.. image:: _build/assets/examples/loft.png
:align: center
This example demonstrates lofting a set of sketches, selecting
@ -535,7 +536,7 @@ the top and bottom by type, and shelling.
Peg Board Hook
--------------
.. image:: assets/examples/peg_board_hook.png
.. image:: _build/assets/examples/peg_board_hook.png
:align: center
This script creates a a J-shaped pegboard hook. These hooks are commonly used for
@ -564,7 +565,7 @@ to aid 3D printing.
Platonic Solids
---------------
.. image:: assets/examples/platonic_solids.png
.. image:: _build/assets/examples/platonic_solids.png
:align: center
This example creates a custom Part object PlatonicSolid.
@ -590,7 +591,7 @@ embodying ideals of symmetry and balance.
Playing Cards
-------------
.. image:: assets/examples/playing_cards.png
.. image:: _build/assets/examples/playing_cards.png
:align: center
This example creates a customs Sketch objects: Club, Spade, Heart, Diamond,
@ -609,7 +610,7 @@ imported as code from an SVG file and modified to the code found here.
Stud Wall
---------
.. image:: assets/examples/stud_wall.png
.. image:: _build/assets/examples/stud_wall.png
:align: center
This example demonstrates creating custom `Part` objects and putting them into
@ -629,7 +630,7 @@ are used to position all of objects.
Tea Cup
-------
.. image:: assets/examples/tea_cup.png
.. image:: _build/assets/examples/tea_cup.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -667,7 +668,7 @@ The tea cup model involves several CAD techniques, such as:
Toy Truck
---------
.. image:: assets/examples/toy_truck.png
.. image:: _build/assets/examples/toy_truck.png
:align: center
.. image:: assets/examples/toy_truck_picture.jpg
@ -691,7 +692,7 @@ build123d.
Vase
----
.. image:: assets/examples/vase.png
.. image:: _build/assets/examples/vase.png
:align: center
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
@ -733,10 +734,10 @@ selecting edges by position range and type for the application of fillets
{name-of-your-example-with-spaces}
--------------------------------
.. image:: assets/examples/example_{name-of-your-example}_01.{extension}
.. image:: _build/assets/examples/{name-of-your-example}.{extension}
:align: center
.. image:: assets/examples/example_{name-of-your-example}_02.{extension}
.. image:: _build/assets/examples/{name-of-your-example-detail}.{extension}
:align: center
.. dropdown:: info

View file

@ -47,7 +47,7 @@ def write_svg():
exporter.add_layer("Hidden", line_color=(99, 99, 99), line_type=LineType.ISO_DOT)
exporter.add_shape(visible, layer="Visible")
exporter.add_shape(hidden, layer="Hidden")
exporter.write(f"assets/general_ex{example_counter}.svg")
exporter.write(f"general_ex{example_counter}.svg")
##########################################

View file

@ -33,25 +33,25 @@
About
########
Build123d is a Python-based, parametric (BREP) modeling framework for 2D and 3D CAD.
Built on the Open Cascade geometric kernel, it provides a clean, fully Pythonic interface
for creating precise models suitable for 3D printing, CNC machining, laser cutting, and
other manufacturing processes. Models can be exported to popular CAD tools such as FreeCAD
Build123d is a Python-based, parametric (BREP) modeling framework for 2D and 3D CAD.
Built on the Open Cascade geometric kernel, it provides a clean, fully Pythonic interface
for creating precise models suitable for 3D printing, CNC machining, laser cutting, and
other manufacturing processes. Models can be exported to popular CAD tools such as FreeCAD
and SolidWorks.
Designed for modern, maintainable CAD-as-code, build123d combines clear architecture with
Designed for modern, maintainable CAD-as-code, build123d combines clear architecture with
expressive, algebraic modeling. It offers:
* Minimal or no internal state depending on mode
* Explicit 1D, 2D, and 3D geometry classes with well-defined operations
* Extensibility through subclassing and functional composition—no monkey patching
* Standards-compliant code (PEP 8, mypy, pylint) with rich pylance type hints
* Deep Python integration—selectors as lists, locations as iterables, and natural
* Deep Python integration—selectors as lists, locations as iterables, and natural
conversions (``Solid(shell)``, ``tuple(Vector)``)
* Operator-driven modeling (``obj += sub_obj``, ``Plane.XZ * Pos(X=5) * Rectangle(1, 1)``)
* Operator-driven modeling (``obj += sub_obj``, ``Plane.XZ * Pos(X=5) * Rectangle(1, 1)``)
for algebraic, readable, and composable design logic
With build123d, intricate parametric models can be created in just a few lines of readable
With build123d, intricate parametric models can be created in just a few lines of readable
Python code—as demonstrated by the tea cup example below.
.. dropdown:: Teacup Example
@ -64,7 +64,7 @@ Python code—as demonstrated by the tea cup example below.
.. raw:: html
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
<model-viewer poster="_images/tea_cup.png" src="_static/tea_cup.glb" alt="A tea cup modelled in build123d" auto-rotate camera-controls style="width: 100%; height: 50vh;"></model-viewer>
<model-viewer poster="_images/tea_cup.png" src="_build/assets/examples/tea_cup.glb" alt="A tea cup modelled in build123d" auto-rotate camera-controls style="width: 100%; height: 50vh;"></model-viewer>
.. note::

View file

@ -30,19 +30,19 @@ They are organized from simple to complex, so working through them in order is t
Just about the simplest possible example, a rectangular :class:`~objects_part.Box`.
.. image:: assets/general_ex1.svg
.. image:: _build/assets/general_examples/general_ex1.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 1]
:end-before: [Ex. 1]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 1]
:end-before: [Ex. 1]
@ -55,7 +55,7 @@ Just about the simplest possible example, a rectangular :class:`~objects_part.Bo
A rectangular box, but with a hole added.
.. image:: assets/general_ex2.svg
.. image:: _build/assets/general_examples/general_ex2.svg
:align: center
* **Builder mode**
@ -64,7 +64,7 @@ A rectangular box, but with a hole added.
:class:`~build_enums.Mode` ``.SUBTRACT`` to cut the :class:`~objects_part.Cylinder`
from the :class:`~objects_part.Box`.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 2]
:end-before: [Ex. 2]
@ -75,7 +75,7 @@ A rectangular box, but with a hole added.
the subtract operator ``-`` to cut the :class:`~objects_part.Cylinder`
from the :class:`~objects_part.Box`.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 2]
:end-before: [Ex. 2]
@ -88,7 +88,7 @@ A rectangular box, but with a hole added.
Build a prismatic solid using extrusion.
.. image:: assets/general_ex3.svg
.. image:: _build/assets/general_examples/general_ex3.svg
:align: center
* **Builder mode**
@ -97,7 +97,7 @@ Build a prismatic solid using extrusion.
:class:`~objects_sketch.Circle` and a subtracted :class:`~objects_sketch.Rectangle`
and then use :class:`~build_part.BuildPart`'s :meth:`~operations_part.extrude` feature.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 3]
:end-before: [Ex. 3]
@ -107,7 +107,7 @@ Build a prismatic solid using extrusion.
This time we can first create a 2D :class:`~objects_sketch.Circle` with a subtracted
:class:`~objects_sketch.Rectangle`` and then use the :meth:`~operations_part.extrude` operation for parts.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 3]
:end-before: [Ex. 3]
@ -122,7 +122,7 @@ Sometimes you need to build complex profiles using lines and arcs. This example
builds a prismatic solid from 2D operations. It is not necessary to create
variables for the line segments, but it will be useful in a later example.
.. image:: assets/general_ex4.svg
.. image:: _build/assets/general_examples/general_ex4.svg
:align: center
* **Builder mode**
@ -131,7 +131,7 @@ variables for the line segments, but it will be useful in a later example.
:meth:`~operations_sketch.make_face` is used to convert the pending line segments
from :class:`~build_line.BuildLine` into a closed Face.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 4]
:end-before: [Ex. 4]
@ -144,7 +144,7 @@ variables for the line segments, but it will be useful in a later example.
The operation :meth:`~operations_sketch.make_face` is used to convert the line
segments into a Face.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 4]
:end-before: [Ex. 4]
@ -157,7 +157,7 @@ Note that to build a closed face it requires line segments that form a closed sh
---------------------------------------------------
.. image:: assets/general_ex5.svg
.. image:: _build/assets/general_examples/general_ex5.svg
:align: center
* **Builder mode**
@ -165,7 +165,7 @@ Note that to build a closed face it requires line segments that form a closed sh
Using :class:`~build_common.Locations` we can place one (or multiple) objects
at one (or multiple) places.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 5]
:end-before: [Ex. 5]
@ -176,7 +176,7 @@ Note that to build a closed face it requires line segments that form a closed sh
object to the provided position. Using ``Rot(x_angle, y_angle, z_angle) * obj``
(with :class:`geometry.Rot`) would rotate the object.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 5]
:end-before: [Ex. 5]
@ -190,14 +190,14 @@ Note that to build a closed face it requires line segments that form a closed sh
Sometimes you need to create a number of features at various
:class:`~build_common.Locations`.
.. image:: assets/general_ex6.svg
.. image:: _build/assets/general_examples/general_ex6.svg
:align: center
* **Builder mode**
You can use a list of points to construct multiple objects at once.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 6]
:end-before: [Ex. 6]
@ -210,7 +210,7 @@ Sometimes you need to create a number of features at various
The algebra operations are vectorized, which means ``obj - [obj1, obj2, obj3]``
is short for ``obj - obj1 - obj2 - ob3`` (and more efficient, see :ref:`algebra_performance`).
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 6]
:end-before: [Ex. 6]
@ -221,7 +221,7 @@ Sometimes you need to create a number of features at various
7. Polygons
---------------------------------------------------
.. image:: assets/general_ex7.svg
.. image:: _build/assets/general_examples/general_ex7.svg
:align: center
* **Builder mode**
@ -229,7 +229,7 @@ Sometimes you need to create a number of features at various
You can create :class:`~objects_sketch.RegularPolygon` for each stack point if
you would like.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 7]
:end-before: [Ex. 7]
@ -239,7 +239,7 @@ Sometimes you need to create a number of features at various
You can apply locations to :class:`~objects_sketch.RegularPolygon` instances
for each location via loops or list comprehensions.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 7]
:end-before: [Ex. 7]
@ -255,19 +255,19 @@ of chained points connected by lines. This example uses a polyline to create
one half of an i-beam shape, which is :meth:`~operations_generic.mirror` ed to
create the final profile.
.. image:: assets/general_ex8.svg
.. image:: _build/assets/general_examples/general_ex8.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 8]
:end-before: [Ex. 8]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 8]
:end-before: [Ex. 8]
@ -283,19 +283,19 @@ and :meth:`~operations_generic.fillet` can be used to "bevel" and "round" edges
these two methods require an edge or a list of edges to operate on. To select all
edges, you could simply pass in ``ex9.edges()``.
.. image:: assets/general_ex9.svg
.. image:: _build/assets/general_examples/general_ex9.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 9]
:end-before: [Ex. 9]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 9]
:end-before: [Ex. 9]
@ -311,7 +311,7 @@ be the highest z-dimension group.
---------------------------------------------------
.. image:: assets/general_ex10.svg
.. image:: _build/assets/general_examples/general_ex10.svg
:align: center
* **Builder mode**
@ -320,7 +320,7 @@ be the highest z-dimension group.
It is used to perform a :meth:`~operations_generic.fillet` in this example. This example also
makes use of :class:`~objects_part.Hole` which automatically cuts through the entire part.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 10]
:end-before: [Ex. 10]
@ -332,7 +332,7 @@ be the highest z-dimension group.
It is used to perform a :meth:`~operations_generic.fillet` in this example. This example also makes use
of :class:`~objects_part.Hole`. Different to the *context mode*, you have to add the ``depth`` of the whole.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 10]
:end-before: [Ex. 10]
@ -344,7 +344,7 @@ be the highest z-dimension group.
----------------------------------------------------------------------------
.. image:: assets/general_ex11.svg
.. image:: _build/assets/general_examples/general_ex11.svg
:align: center
* **Builder mode**
@ -358,7 +358,7 @@ be the highest z-dimension group.
Lastly, :meth:`~operations_part.extrude` can be used with a negative amount and ``Mode.SUBTRACT`` to
cut these from the parent.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 11]
:end-before: [Ex. 11]
@ -375,7 +375,7 @@ be the highest z-dimension group.
Lastly, :meth:`~operations_part.extrude` can be used with a negative amount and cut (``-``) from the
parent.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 11]
:end-before: [Ex. 11]
@ -392,19 +392,19 @@ if the extrude direction and mode/operation (ADD / ``+`` or SUBTRACT / ``-``) ar
This example defines a side using a spline curve through a collection of points. Useful when you have an
edge that needs a complex profile.
.. image:: assets/general_ex12.svg
.. image:: _build/assets/general_examples/general_ex12.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 12]
:end-before: [Ex. 12]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 12]
:end-before: [Ex. 12]
@ -417,14 +417,14 @@ edge that needs a complex profile.
Counter-sink and counter-bore holes are useful for creating recessed areas for fasteners.
.. image:: assets/general_ex13.svg
.. image:: _build/assets/general_examples/general_ex13.svg
:align: center
* **Builder mode**
We use a face to establish a location for :class:`~build_common.Locations`.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 13]
:end-before: [Ex. 13]
@ -434,7 +434,7 @@ Counter-sink and counter-bore holes are useful for creating recessed areas for f
We use a face to establish a plane that is used later in the code for locating objects
onto this plane.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 13]
:end-before: [Ex. 13]
@ -456,7 +456,7 @@ consuming, and more difficult to maintain. The pending faces must lie on the
path, please see example 37 for a way to make this placement easier.
.. image:: assets/general_ex14.svg
.. image:: _build/assets/general_examples/general_ex14.svg
:align: center
* **Builder mode**
@ -465,7 +465,7 @@ path, please see example 37 for a way to make this placement easier.
path (in this case the path is taken from the pending edges from ``ex14_ln``).
:meth:`~operations_part.revolve` requires a single connected wire.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 14]
:end-before: [Ex. 14]
@ -475,7 +475,7 @@ path, please see example 37 for a way to make this placement easier.
The :meth:`~operations_generic.sweep` method takes any faces and sweeps them through the provided
path (in this case the path is taken from ``ex14_ln``).
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 14]
:end-before: [Ex. 14]
@ -493,12 +493,12 @@ Additionally the '@' operator is used to simplify the line segment commands.
``(l4 @ 1).Y`` is used to extract the y-component of the ``l4 @ 1`` vector.
.. image:: assets/general_ex15.svg
.. image:: _build/assets/general_examples/general_ex15.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 15]
:end-before: [Ex. 15]
@ -507,7 +507,7 @@ Additionally the '@' operator is used to simplify the line segment commands.
Combine lines via the pattern ``Curve() + [l1, l2, l3, l4, l5]``
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 15]
:end-before: [Ex. 15]
@ -520,19 +520,19 @@ Additionally the '@' operator is used to simplify the line segment commands.
Mirror can also be used with BuildPart (and BuildSketch) to mirror 3D objects.
The ``Plane.offset()`` method shifts the plane in the normal direction (positive or negative).
.. image:: assets/general_ex16.svg
.. image:: _build/assets/general_examples/general_ex16.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 16]
:end-before: [Ex. 16]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 16]
:end-before: [Ex. 16]
@ -546,19 +546,19 @@ The ``Plane.offset()`` method shifts the plane in the normal direction (positive
Here we select the farthest face in the Y-direction and turn it into a :class:`~geometry.Plane` using the
``Plane()`` class.
.. image:: assets/general_ex17.svg
.. image:: _build/assets/general_examples/general_ex17.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 17]
:end-before: [Ex. 17]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 17]
:end-before: [Ex. 17]
@ -572,14 +572,14 @@ Here we select the farthest face in the Y-direction and turn it into a :class:`~
Here we start with an earlier example, select the top face, draw a rectangle and then use Extrude
with a negative distance.
.. image:: assets/general_ex18.svg
.. image:: _build/assets/general_examples/general_ex18.svg
:align: center
* **Builder mode**
We then use ``Mode.SUBTRACT`` to cut it out from the main body.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 18]
:end-before: [Ex. 18]
@ -588,7 +588,7 @@ with a negative distance.
We then use ``-=`` to cut it out from the main body.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 18]
:end-before: [Ex. 18]
@ -604,7 +604,7 @@ Firstly ``vtx`` uses :meth:`~topology.ShapeList.group_by` and ``Axis.X`` to sele
defined Axis ``vtx2Axis`` that is pointing roughly in the direction of a vertex to select, and then :meth:`~topology.ShapeList.sort_by`
this custom Axis.
.. image:: assets/general_ex19.svg
.. image:: _build/assets/general_examples/general_ex19.svg
:align: center
* **Builder mode**
@ -613,7 +613,7 @@ this custom Axis.
as center points for two circles that cut through the main part. Note that if you passed the variable ``vtx`` directly to
:class:`~build_common.Locations` then the part would be offset from the workplane by the vertex z-position.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 19]
:end-before: [Ex. 19]
@ -624,7 +624,7 @@ this custom Axis.
that cut through the main part. Note that if you passed the variable ``vtx`` directly to
:class:`~geometry.Pos` then the part would be offset from the workplane by the vertex z-position.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 19]
:end-before: [Ex. 19]
@ -638,19 +638,19 @@ this custom Axis.
The ``plane`` variable is set to be coincident with the farthest face in the
negative x-direction. The resulting Plane is offset from the original position.
.. image:: assets/general_ex20.svg
.. image:: _build/assets/general_examples/general_ex20.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 20]
:end-before: [Ex. 20]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 20]
:end-before: [Ex. 20]
@ -664,19 +664,19 @@ negative x-direction. The resulting Plane is offset from the original position.
One cylinder is created, and then the origin and z_dir of that part are used to create a new Plane for
positioning another cylinder perpendicular and halfway along the first.
.. image:: assets/general_ex21.svg
.. image:: _build/assets/general_examples/general_ex21.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 21]
:end-before: [Ex. 21]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 21]
:end-before: [Ex. 21]
@ -690,14 +690,14 @@ positioning another cylinder perpendicular and halfway along the first.
It is also possible to create a rotated workplane, building upon some of the concepts in an earlier
example.
.. image:: assets/general_ex22.svg
.. image:: _build/assets/general_examples/general_ex22.svg
:align: center
* **Builder mode**
Use the :meth:`~geometry.Plane.rotated` method to rotate the workplane.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 22]
:end-before: [Ex. 22]
@ -706,7 +706,7 @@ example.
Use the operator ``*`` to relocate the plane (post-multiplication!).
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 22]
:end-before: [Ex. 22]
@ -728,19 +728,19 @@ only one side of the Sketch.
It is highly recommended to view your sketch before you attempt to call revolve.
.. image:: assets/general_ex23.svg
.. image:: _build/assets/general_examples/general_ex23.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 23]
:end-before: [Ex. 23]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 23]
:end-before: [Ex. 23]
@ -756,19 +756,19 @@ conical-like shape from a circle and a rectangle that is offset vertically. In t
:meth:`~operations_part.loft` automatically takes the pending faces that were added by the two BuildSketches.
Loft can behave unexpectedly when the input faces are not parallel to each other.
.. image:: assets/general_ex24.svg
.. image:: _build/assets/general_examples/general_ex24.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 24]
:end-before: [Ex. 24]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 24]
:end-before: [Ex. 24]
@ -779,14 +779,14 @@ Loft can behave unexpectedly when the input faces are not parallel to each other
25. Offset Sketch
---------------------------------------------------
.. image:: assets/general_ex25.svg
.. image:: _build/assets/general_examples/general_ex25.svg
:align: center
* **Builder mode**
BuildSketch faces can be transformed with a 2D :meth:`~operations_generic.offset`.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 25]
:end-before: [Ex. 25]
@ -795,7 +795,7 @@ Loft can behave unexpectedly when the input faces are not parallel to each other
Sketch faces can be transformed with a 2D :meth:`~operations_generic.offset`.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 25]
:end-before: [Ex. 25]
@ -816,19 +816,19 @@ using very few operations. This can also be offset inwards or outwards. Faces ca
Note that self intersecting edges and/or faces can break both 2D and 3D offsets.
.. image:: assets/general_ex26.svg
.. image:: _build/assets/general_examples/general_ex26.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 26]
:end-before: [Ex. 26]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 26]
:end-before: [Ex. 26]
@ -842,19 +842,19 @@ Note that self intersecting edges and/or faces can break both 2D and 3D offsets.
You can split an object using a plane, and retain either or both halves. In this case we select
a face and offset half the width of the box.
.. image:: assets/general_ex27.svg
.. image:: _build/assets/general_examples/general_ex27.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 27]
:end-before: [Ex. 27]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 27]
:end-before: [Ex. 27]
@ -865,7 +865,7 @@ a face and offset half the width of the box.
28. Locating features based on Faces
---------------------------------------------------
.. image:: assets/general_ex28.svg
.. image:: _build/assets/general_examples/general_ex28.svg
:align: center
* **Builder mode**
@ -873,7 +873,7 @@ a face and offset half the width of the box.
We create a triangular prism with :class:`~build_enums.Mode` ``.PRIVATE`` and then later
use the faces of this object to cut holes in a sphere.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 28]
:end-before: [Ex. 28]
@ -882,7 +882,7 @@ a face and offset half the width of the box.
We create a triangular prism and then later use the faces of this object to cut holes in a sphere.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 28]
:end-before: [Ex. 28]
@ -899,19 +899,19 @@ build123d is based on the OpenCascade.org (OCC) modeling Kernel. Those who are f
know about the famous bottle example. We use a 3D Offset and the openings parameter to create
the bottle opening.
.. image:: assets/general_ex29.svg
.. image:: _build/assets/general_examples/general_ex29.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 29]
:end-before: [Ex. 29]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 29]
:end-before: [Ex. 29]
@ -926,19 +926,19 @@ Here ``pts`` is used as an input to both :class:`~objects_curve.Polyline` and
:class:`~objects_curve.Bezier` and ``wts`` to Bezier alone. These two together
create a closed line that is made into a face and extruded.
.. image:: assets/general_ex30.svg
.. image:: _build/assets/general_examples/general_ex30.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 30]
:end-before: [Ex. 30]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 30]
:end-before: [Ex. 30]
@ -953,19 +953,19 @@ Locations contexts can be nested to create groups of shapes. Here 24 triangles,
1 hexagon are created and then extruded. Notably :class:`~build_common.PolarLocations`
rotates any "children" groups by default.
.. image:: assets/general_ex31.svg
.. image:: _build/assets/general_examples/general_ex31.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 31]
:end-before: [Ex. 31]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 31]
:end-before: [Ex. 31]
@ -980,7 +980,7 @@ In this example, a standard python for-loop is used along with a list of faces e
to progressively modify the extrusion amount. There are 7 faces in the sketch, so this results in 7
separate calls to :meth:`~operations_part.extrude`.
.. image:: assets/general_ex32.svg
.. image:: _build/assets/general_examples/general_ex32.svg
:align: center
* **Builder mode**
@ -988,14 +988,14 @@ separate calls to :meth:`~operations_part.extrude`.
:class:`~build_enums.Mode` ``.PRIVATE`` is used in :class:`~build_sketch.BuildSketch` to avoid
adding these faces until the for-loop.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 32]
:end-before: [Ex. 32]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 32]
:end-before: [Ex. 32]
@ -1010,14 +1010,14 @@ Building on the previous example, a standard python function is used to return
a sketch as a function of several inputs to
progressively modify the size of each square.
.. image:: assets/general_ex33.svg
.. image:: _build/assets/general_examples/general_ex33.svg
:align: center
* **Builder mode**
The function returns a :class:`~build_sketch.BuildSketch`.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 33]
:end-before: [Ex. 33]
@ -1026,7 +1026,7 @@ progressively modify the size of each square.
The function returns a ``Sketch`` object.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 33]
:end-before: [Ex. 33]
@ -1037,7 +1037,7 @@ progressively modify the size of each square.
34. Embossed and Debossed Text
---------------------------------------------------
.. image:: assets/general_ex34.svg
.. image:: _build/assets/general_examples/general_ex34.svg
:align: center
* **Builder mode**
@ -1048,7 +1048,7 @@ progressively modify the size of each square.
ran ``BuildSketch(ex34.faces().sort_by(Axis.Z)[-1])`` for both ``ex34_sk1 & 2`` it would incorrectly locate
the 2nd "World" text on the top of the "Hello" text.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 34]
:end-before: [Ex. 34]
@ -1059,7 +1059,7 @@ progressively modify the size of each square.
top face (``topf``). Note that :class:`~build_enums.Align` is used to control the text placement. We re-use
the ``topf`` variable to select the same face and deboss (indented) the text "World".
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 34]
:end-before: [Ex. 34]
@ -1070,7 +1070,7 @@ progressively modify the size of each square.
35. Slots
---------------------------------------------------
.. image:: assets/general_ex35.svg
.. image:: _build/assets/general_examples/general_ex35.svg
:align: center
* **Builder mode**
@ -1079,7 +1079,7 @@ progressively modify the size of each square.
:class:`~build_line.BuildLine` and :class:`~objects_curve.RadiusArc` to create an
arc for two instances of :class:`~objects_sketch.SlotArc`.
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 35]
:end-before: [Ex. 35]
@ -1089,7 +1089,7 @@ progressively modify the size of each square.
Here we create a :class:`~objects_sketch.SlotCenterToCenter` and then use
a :class:`~objects_curve.RadiusArc` to create an arc for two instances of :class:`~operations_sketch.SlotArc`.
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 35]
:end-before: [Ex. 35]
@ -1105,19 +1105,19 @@ where you might not know easily the distance you have to extrude to. In such
cases you can use :meth:`~operations_part.extrude` :class:`~build_enums.Until`
with ``Until.NEXT`` or ``Until.LAST``.
.. image:: assets/general_ex36.svg
.. image:: _build/assets/general_examples/general_ex36.svg
:align: center
* **Builder mode**
.. literalinclude:: general_examples.py
.. literalinclude:: general_examples/examples/general_examples.py
:language: build123d
:start-after: [Ex. 36]
:end-before: [Ex. 36]
* **Algebra mode**
.. literalinclude:: general_examples_algebra.py
.. literalinclude:: general_examples/examples/general_examples_algebra.py
:language: build123d
:start-after: [Ex. 36]
:end-before: [Ex. 36]

View file

@ -2,9 +2,7 @@ import os
from build123d import *
from ocp_vscode import *
working_path = os.path.dirname(os.path.abspath(__file__))
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
from tcv_screenshots import save_model
with BuildPart() as part:
with BuildSketch() as s:
@ -46,5 +44,4 @@ with BuildPart() as part:
for i, f in enumerate(faces):
RigidJoint(f"bearing_bore_{i}", joint_location=f.center_location)
show(part, [f.translate(f.normal_at() * 0.01) for f in faces], render_joints=True)
save_screenshot(os.path.join(filedir, "filter_all_edges_circle.png"))
save_model([part, *[f.translate(f.normal_at() * 0.01) for f in faces]], "filter_all_edges_circle", {"render_joints": True})

View file

@ -3,6 +3,8 @@ import os
from build123d import *
from ocp_vscode import *
from tcv_screenshots import save_model
working_path = os.path.dirname(os.path.abspath(__file__))
filedir = os.path.join(working_path, "..", "..", "assets", "topology_selection")
@ -20,7 +22,7 @@ motor_bore = motor_face.inner_wires().edges().filter_by(lambda e: e.radius == 16
location = Location(motor_bore.arc_center, motor_bore.normal() * 90, Intrinsic.YXZ)
RigidJoint(f"motor", bracket, joint_location=location)
before_linear = copy(bracket)
save_model(bracket, "filter_inner_wire_count", {"render_joints": True})
mount_face = faces.filter_by(lambda f: len(f.inner_wires()) == 6).sort_by(Axis.Z)[-1]
mount_slots = mount_face.inner_wires().edges().filter_by(GeomType.CIRCLE)
@ -31,8 +33,4 @@ joint_edges = [
for i, e in enumerate(joint_edges):
LinearJoint(f"mount_m4_{i}", bracket, axis=Axis(e), linear_range=(0, e.length / 2))
show(before_linear, render_joints=True)
save_screenshot(os.path.join(filedir, "filter_inner_wire_count.png"))
show(bracket, render_joints=True)
save_screenshot(os.path.join(filedir, "filter_inner_wire_count_linear.png"))
save_model(bracket, "filter_inner_wire_count_linear", {"render_joints": True})

View file

@ -17,69 +17,70 @@ visit `Toby's youtube channel <https://www.Youtube.com/TooTallToby>`_.
Feel free to click on the parts below to embark on these engaging challenges.
.. grid:: 3
:gutter: 3
.. grid-item-card:: Party Pack 01-01 Bearing Bracket
:img-top: assets/ttt/ttt-ppp0101_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0101.png
:link: ttt-ppp0101
:link-type: ref
.. grid-item-card:: Party Pack 01-02 Post Cap
:img-top: assets/ttt/ttt-ppp0102_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0102.png
:link: ttt-ppp0102
:link-type: ref
.. grid-item-card:: Party Pack 01-03 C Clamp Base
:img-top: assets/ttt/ttt-ppp0103_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0103.png
:link: ttt-ppp0103
:link-type: ref
.. grid-item-card:: Party Pack 01-04 Angle Bracket
:img-top: assets/ttt/ttt-ppp0104_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0104.png
:link: ttt-ppp0104
:link-type: ref
.. grid-item-card:: Party Pack 01-05 Paste Sleeve
:img-top: assets/ttt/ttt-ppp0105_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0105.png
:link: ttt-ppp0105
:link-type: ref
.. grid-item-card:: Party Pack 01-06 Bearing Jig
:img-top: assets/ttt/ttt-ppp0106_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0106.png
:link: ttt-ppp0106
:link-type: ref
.. grid-item-card:: Party Pack 01-07 Flanged Hub
:img-top: assets/ttt/ttt-ppp0107_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0107.png
:link: ttt-ppp0107
:link-type: ref
.. grid-item-card:: Party Pack 01-08 Tie Plate
:img-top: assets/ttt/ttt-ppp0108_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0108.png
:link: ttt-ppp0108
:link-type: ref
.. grid-item-card:: Party Pack 01-09 Corner Tie
:img-top: assets/ttt/ttt-ppp0109_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0109.png
:link: ttt-ppp0109
:link-type: ref
.. grid-item-card:: Party Pack 01-10 Light Cap
:img-top: assets/ttt/ttt-ppp0110_object.png
:img-top: _build/assets/ttt/thumb_ttt-ppp0110.png
:link: ttt-ppp0110
:link-type: ref
.. grid-item-card:: 23-02-02 SM Hanger
:img-top: assets/ttt/ttt-23-02-02-sm_hanger_object.png
:img-top: _build/assets/ttt/thumb_ttt-23-02-02-sm_hanger.png
:link: ttt-23-02-02-sm_hanger
:link-type: ref
.. grid-item-card:: 23-T-24 Curved Support
:img-top: assets/ttt/ttt-23-t-24-curved_support_object.png
:img-top: _build/assets/ttt/thumb_ttt-23-t-24-curved_support.png
:link: ttt-23-t-24
:link-type: ref
.. grid-item-card:: 24-SPO-06 Buffer Stand
:img-top: assets/ttt/ttt-24-SPO-06-Buffer_Stand_object.png
:img-top: _build/assets/ttt/thumb_ttt-24-SPO-06-Buffer_Stand.png
:link: ttt-24-spo-06
:link-type: ref