Skip to main content

Render PythonSCAD design scripts to STL files, including customizer presets.

Project description

PythonSCAD STL Generator

PythonSCAD STL Generator is a small command line tool for batch-rendering PythonSCAD design files. It scans a directory for Python files that import pythonscad, renders each design with the pythonscad executable from PATH, and optionally renders once per customizer preset from a sibling JSON file.

Installation

Install the published package with pipx:

pipx install pythonscad-stl-generator

Or install it into an existing environment with pip:

python -m pip install pythonscad-stl-generator

For development:

git clone https://github.com/nomike/pythonscad-stl-generator.git
cd pythonscad-stl-generator
python -m pip install -e ".[dev]"

PythonSCAD itself is not bundled. The tool expects a pythonscad executable to be available on PATH, or you can point to it explicitly with --pythonscad=/path/to/pythonscad.

Usage

From a directory containing PythonSCAD designs:

generate-pythonscad-stls

The command writes STL files to output/ by default. A Python file is treated as a design when it imports pythonscad, for example:

from pythonscad import *

width = add_parameter("width", 20)
cube([width, width, width]).show()

Useful options:

generate-pythonscad-stls --output-dir stls
generate-pythonscad-stls --pythonscad ~/bin/pythonscad
generate-pythonscad-stls --format 3mf
generate-pythonscad-stls --dry-run --verbose
generate-pythonscad-stls --recursive

The generated PythonSCAD command includes --trust-python, because PythonSCAD requires that flag for command-line execution of Python input files.

Customizer Presets

If box.py has a sibling box.json, the tool reads its top-level parameterSets object and renders once per preset:

{
  "parameterSets": {
    "small": {
      "width": "10"
    },
    "large": {
      "width": "50"
    }
  },
  "fileFormatVersion": "1"
}

This produces files like:

output/box-small.stl
output/box-large.stl

Without a sibling preset file, the design renders once to output/box.stl.

Up-To-Date Checks

Existing output files are skipped when they are newer than their inputs. For a plain design, the input is the .py file. For preset renders, both the .py file and the sibling .json preset file must be older than the output.

Use --force to render everything regardless of timestamps.

Development

Run tests:

python -m pytest

Run linting and formatting:

ruff check .
ruff format .

Run all pre-commit hooks:

pre-commit run --all-files

License

This project is licensed under the MIT License. See LICENSE.

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

pythonscad_stl_generator-0.1.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

pythonscad_stl_generator-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pythonscad_stl_generator-0.1.1.tar.gz.

File metadata

  • Download URL: pythonscad_stl_generator-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pythonscad_stl_generator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e8ba8cffd11a8d32ec7fcb59ee0222ab07f82e890d721b381cc3287b97e6a151
MD5 f52964ab07a9138b607b4aed2ed0b7ae
BLAKE2b-256 4eee8a00dcaf2572d57bd24b16b4e069518fd9992a3ff7814fb882e43f589e13

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonscad_stl_generator-0.1.1.tar.gz:

Publisher: publish-to-pypi.yml on nomike/pythonscad-stl-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pythonscad_stl_generator-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pythonscad_stl_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cee28237a713157793be6f4521d4863936afb94c33e148abd227abedd8d7a838
MD5 8d6da8f68b9fd2aae7e028e79b515b60
BLAKE2b-256 50c905e7b1cb3edda000623fe55c8f5686f86a0cb5f1803a8f02e823e91dff5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pythonscad_stl_generator-0.1.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on nomike/pythonscad-stl-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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