`build123d` ergonomic selector methods
Project description
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
top_edges = base.edges().all_top()
# 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
| Prefix | Behavior | Return Type | Examples |
|---|---|---|---|
| (None) | Returns the single shape at the absolute extreme of the specified vector. | Shape |
top(), bottom_back(), top_front_right() |
all_ |
Returns a subset (group) of shapes sharing the specified extreme boundary. | ShapeList |
all_top(), all_bottom_back(), all_top_front_right() |
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, switch to an all_ prefix or use a fully constrained 2D/3D selector.
Dimensional Selectors
Sorts the ShapeList based on physical size properties (.length for Edges, .area for Faces, and .volume for Solids).
| Method | Description |
|---|---|
largest() |
Returns the single largest shape in the list. |
smallest() |
Returns the single smallest shape in the list. |
Note: Dimensional selectors will raise a ValueError if used on Vertex objects, as they are dimensionless.
Technical Notes
- Evaluation Engine: Under the hood, spatial selectors rely on standard
build123dbounding box centers. Singular selectors chaingroup_byoperations for intermediate axes and conclude with asort_byoperation to extract the exact shape. (i.e.top_front_leftwill retrieve the Z-most group, then Y-least group of those, then sort and pull out the X-least instance). Grouped (all_) selectors exclusively usegroup_byto return subsets.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file b123d_positioning-1.0.0.tar.gz.
File metadata
- Download URL: b123d_positioning-1.0.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1a9a1e7ceeb77e7fbce6c9529e959ae8b8b4d76ff2c07e5f13e03c140a7d6e3
|
|
| MD5 |
b62fc43c0c7faea125145a5a2fc97257
|
|
| BLAKE2b-256 |
e86d1fcda3e1db43a6faadd116e3d2c7bf27c1e0aefc961534de6285ce56dc7a
|
File details
Details for the file b123d_positioning-1.0.0-py3-none-any.whl.
File metadata
- Download URL: b123d_positioning-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97a7bb2fa57eeb0d68e0c5b88a28bf28f28e0d94856b2c347fe52d3d55b8f6c3
|
|
| MD5 |
9954d178e95b96f22043b733feda3c7d
|
|
| BLAKE2b-256 |
8a7bca7ccfab182423837e225fcee6a17ca39a26fb8162d0cd1526c67876a4a0
|