Skip to main content

b123d_positioning

An extension for build123d that installs ergonomic methods for face, edge and vertex selection, e.g. object.vertices().top_front_left().

Usage

Importing the module automatically monkey-patches the build123d.ShapeList class. Your standard objects will immediately possess the new functionality.

import b123d_positioning
from build123d import Box

base = Box(10, 10, 10)

# Extract a single vertex
top_left_corner = base.vertices().top_left()

# Extract a group of edges (pass as_list=True)
top_edges = base.edges().top(as_list=True)

# Extract a face by size
biggest_face = base.faces().largest()

Spatial Selectors

Spatial selectors filter shapes based on their bounding box centers relative to the global 3D coordinate system.

API Grammar

The naming convention strictly follows standard CAD axes:

  • Z-Axis: bottom / top
  • Y-Axis: front / back
  • X-Axis: left / right

Methods can target a single axis or chain up to three dimensions (e.g., bottom_front_left()).

Singular vs. Grouped (as_list=True)

By default, spatial selectors return the single shape at the absolute extreme of the requested vector. If you want to return a subset (group) of all shapes that share that exact boundary, pass as_list=True into the method.

Mode Return Type Examples
Default (as_list=False) Shape top(), bottom_back(), top_front_right()
Grouped (as_list=True) ShapeList top(as_list=True), bottom_back(as_list=True)

Ambiguity Warnings

If you use a singular selector (e.g., .left()) on a dimension where multiple shapes share the exact same extreme coordinate (like the 4 left-most vertices of a 3D box), b123d_positioning will emit a UserWarning. It will still return a single arbitrary shape to prevent crashing your script, but alerts you that the selection is mathematically ambiguous. To resolve the warning, pass as_list=True to select the whole group, or use a fully constrained 2D/3D selector.

Dimensional Selectors

Filters the ShapeList based on physical size properties (.length for Edges, .area for Faces, and .volume for Solids). Just like spatial selectors, dimensional selectors support the as_list=True parameter to return all shapes that tie for that extreme size (within a specified tolerance).

Method Description
largest(as_list=False, tol=1e-5) Returns the largest shape(s) in the list.
smallest(as_list=False, tol=1e-5) Returns the smallest shape(s) in the list.
longest(as_list=False, tol=1e-5) An alias for largest(); improves readability when filtering Edges.
shortest(as_list=False, tol=1e-5) An alias for smallest(); improves readability when filtering Edges.
# Grab all edges tied for the longest length
long_edges = base.edges().longest(as_list=True)

# Grab the single smallest face (will warn if multiple faces tie for smallest)
tiny_face = base.faces().smallest()

Note: Dimensional selectors will raise a ValueError if used on Vertex objects, as they are dimensionless.


Orientation Selectors

Orientation selectors filter shapes based on their angle and alignment in 3D space. To align human intuition with CAD geometry, the vocabulary is specifically tailored to how we visualize lines versus surfaces:

  • Universal Selectors: .horizontal() and .vertical() work across both Edges and Faces. Under the hood, they intelligently evaluate Tangents for Edges and Normals for Faces.
  • Edge Selectors (along_*): Filters edges by the physical path of their line.
  • Face Selectors (facing_*): Filters faces by the direction their surface is "looking" (their normal vector).
Method Supported Shapes Description
horizontal(as_list=False) Edges, Faces Flat surfaces (XY plane) or level-running edges.
vertical(as_list=False) Edges, Faces Upright walls or vertical Z-running edges.
along_x(as_list=False) Edges only Edges running left-to-right parallel to the X-axis.
along_y(as_list=False) Edges only Edges running front-to-back parallel to the Y-axis.
along_z(as_list=False) Edges only Edges running up-and-down (synonym for vertical()).
facing_x(as_list=False) Faces only Outer side walls facing left or right (Normal $\parallel$ X).
facing_y(as_list=False) Faces only Outer front or back walls (Normal $\parallel$ Y).
facing_z(as_list=False) Faces only Top or bottom floors/ceilings (synonym for horizontal()).
# Extract all upright side walls of a model
side_walls = base.faces().vertical(as_list=True)

# Extract only the edges running front-to-back along the Y axis
y_lines = base.edges().along_y(as_list=True)

# Extract the outer left and right facing walls
side_faces = base.faces().facing_x(as_list=True)

Type Guardrails & Tolerances

  • Type Safety: Attempting to use a line-path selector (.along_x()) on a Face, or a surface-normal selector (.facing_x()) on an Edge will immediately raise a descriptive ValueError directing you to the correct method.

  • Ambiguity: Calling an orientation selector with as_list=False (default) when multiple shapes match will emit a UserWarning and return an arbitrary matching shape. Pass as_list=True to safely return the entire group.

Technical Notes

  • Evaluation Engine: Under the hood, spatial selectors rely on standard build123d bounding box centers. To evaluate geometry, the engine chains group_by operations across all specified axes to drill down to the final geometric extreme. If a single shape is requested (as_list=False), it extracts the first instance from that final group. If a subset is requested (as_list=True), it returns the entire final group.

Metadata

Release files for b123D-positioning 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for b123D-positioning 2.1.0
File Size Uploaded
b123d_positioning-2.1.0.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for b123D-positioning 2.1.0
File Interpreter ABI Platform
b123d_positioning-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.2 kB

Release files / b123d_positioning-2.1.0.tar.gz

Download URL b123d_positioning-2.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8061e959b705c0d05d98db4bf772c9365e2dd31de3ed81abb27ff552030b335a
BLAKE2b-256 checksum
How to use checksums
c50ae501bf36bbfd5a4a23fffbdd20d4c04123749aee7e26a85428146940c54c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / b123d_positioning-2.1.0-py3-none-any.whl

Download URL b123d_positioning-2.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed720b2d84040d24eb457f44b90347895672e34f2e59532c9c77090c96e3343d
BLAKE2b-256 checksum
How to use checksums
1c038fd75add38df621a871178da2ebb820dea7b2f63d41b5a4c6eca06c7419a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page