Skip to content
Project's logo

BD Tube boxes

build123d library to create boxes from old tubes.
Preview

Usage:

Code:

Community:

Usage

This library will generate 3 parts to use with a rounded tube (or whatever circular, like glasses, pots, ...):

  • A bottom cap, to be glued on the tube
  • A top cap, to be glued on the tube
  • A lid

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

Or, with requirements.txt:

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

and in a pyproject.yml:

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

Generating boxes

from build123d import export_step
from src.bd_tube_boxes.rounded_canister_threaded import RoundedCanisterThreaded

box = RoundedCanisterThreaded(tube_ext_diameter=50, tube_thickness=1.5)

export_step(box.bottom(), 'box_bottom')
export_step(box.top(), 'box_top')
export_step(box.lid(), 'box_lid')

For more models and 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
# One specific file
python some_part.py

# Predefined task
poe dev_rounded

# Or add a watcher on all .py files and executes "some_file.py" on changes
find . -type f -name "*.py" | entr -s "clear && python some_file.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.

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.