Skip to main content

`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 (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

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 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

b123d_positioning-2.0.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

b123d_positioning-2.0.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file b123d_positioning-2.0.0.tar.gz.

File metadata

  • Download URL: b123d_positioning-2.0.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for b123d_positioning-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0ccb9f28285a44c5e6f05bff2821b68bceebacbae0c818a1d59adb3d88ce39df
MD5 03b32a0c2d5bc39dcf0bfb7f3e81a77c
BLAKE2b-256 7484a5b97f364556adc80e924977412fe3a81b683a6a2f209da3987ff9f73c40

See more details on using hashes here.

File details

Details for the file b123d_positioning-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: b123d_positioning-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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

Hashes for b123d_positioning-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc9bd5a03bada08a2ae1aed331075f82950be3f1c1ca13feba78199701e35e77
MD5 572dea3f18c4bcceb2595e5ca38dfde0
BLAKE2b-256 a10b1910c2a39d7e8ea825d9dda58aec834bd44b43c0cb52bf825f2e355aa203

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page