Skip to content

Build123d - parts

build123d library to generate various models.

Code:

Community:

Usage

Setup

There is no pypi module for now; use the git repository. If you need a specific reference, append it to the repository url with @<ref>.

This library don't use the pypi version of build123d, as we rely on unreleased features. Check pyproject.toml to see the git reference.

Pip:

pip install git+https://gitlab.com/experimentslabs/3d/bd_el_parts.git

Or, with requirements.txt:

bd_el_parts @ git+https://gitlab.com/experimentslabs/3d/bd_el_parts.git

and in a pyproject.yml:

dependencies= [
  #...
  "bd_el_parts @ git+https://gitlab.com/experimentslabs/3d/bd_el_parts.git",
]

Then:

# Usage example to be determined

For more parameters, check the API documentation.

Contributing

Bug reports and pull requests are welcome on the issue tracker at GitLab. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Setup

First of all, clone the repository.

The following steps creates a Python virtual environment to develop this project. If you already have an environment for Build123d projects, it may be enough.

Let's just say the project successfully builds with the Build123d version specified in requirements.txt.

  1. Create a Python environment:
pyenv install 3.13
pyenv virtualenv 3.13 build123d
  1. Activate the env:
pyenv local build123d
  1. Install dependencies:
pip install --editable '.[dev]'

Now, code :)

There is a file, dev.py which has a lot of boilerplate to help in developing specific parts of the library. Feel free to edit it if needed. It relies on show_object and other methods from ocp_vscode, so either edit the code in VSCodium with the right plugin, or start the viewer server manually (check the section right after).

OCP VSCode without VSCodium

To use ocp_vscode to develop the parts, but without VSCodium:

  1. Manually start the server
python -m ocp_vscode
# Open your browser at the given URL
  1. Manually render the files or use a watcher
python some_part.py # One specific file

# Or add a watcher on all .py files and executes "dev.py" on changes
find . -type f -name "*.py" | entr -s "clear && python dev.py"

Feel free to change dev.py during the development, and commit your pertinent changes

Tools

Use diff3d (included in the .[tools] dependencies) to compare generated models:

diff3d model1.step model2.step

Linting and formatting

To check all the code:

poe lint-check

To fix what is fixable automatically:

poe lint-fix

Checking licenses

To help ensuring the project has a valid license, run licensecheck; it will compare the license with the ones of the dependencies.

You only have to run it when dependencies changes.

Testing

Run unit tests with:

pytest

Documentation

Documentation is generated in CI. To generate it locally:

# Copies markdown files and generate pictures; there is no need to run it
# every time.
scripts/prepare_documentation.sh

# Serve documentation locally
poe docs-serve
# Open your browser at the link given by the server.

Notes about scripts/prepare_documentation.sh:

  • prepare_documentation.sh will replace the rgb(17,17,17) color with CSS's currentcolor in all SVGs to adapt generated files to both light and dark modes
  • To create a note compatible in both mkdoc and Gitlab, create one line notes with this format: !!! note "The note. It" will be nicely displayed for people browsing from Gitlab, and will be converted to admonitions in mkdocs

License

This library is available as open source under the terms of the GPL v3 License.

Code of Conduct

Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.