Skip to main content

An AST evaluator for the OpenSCAD language, producing Manifold CSG geometry from a parsed AST.

Project description

openscad_evaluator

An AST evaluator for the OpenSCAD language, producing Manifold CSG geometry from a parsed AST.

Tests PyPI version License: MIT

Overview

openscad_evaluator takes an OpenSCAD AST — as produced by openscad_lalr_parser — and walks it to produce Manifold meshes: a two-pass resolve (AST walk, no CSG calls) then generate (bottom-up Manifold/CrossSection construction) pipeline, with $fn/$fa/$fs, full built-in coverage (primitives, transforms, boolean ops, 2D geometry, text(), surface(), DXF/3MF import, roof()), and a content-hash geometry cache (ManifoldCache) so repeated renders/debugger pauses skip unchanged Manifold work.

It's GUI- and toolkit-agnostic: the only way it talks back to a caller is a handful of optional callback parameters on Evaluator.__init__ (echo_fn, debug_hook, error_break_fn, return_hook) — no QObject, no signals, no direct rendering. This is the evaluator that powers BelfrySCAD.

See docs/evaluator.md for the full architecture reference: scope processing, assignment order, the built-ins table, 2D/3D geometry handling, error format, $variables scoping, include/use, and the Manifold provenance / AST-to-geometry-ID mapping used for WYSIWYG picking.

Installation

pip install openscad-evaluator

For DXF import support:

pip install openscad-evaluator[dxf]

From Source

git clone https://github.com/BelfrySCAD/openscad_evaluator.git
cd openscad_evaluator
pip install -e ".[dev]"

Quick Start

from openscad_lalr_parser import getASTfromString, build_scopes
from openscad_evaluator import Evaluator

nodes = getASTfromString("cube([10, 10, 10]);")
root_scope = build_scopes(nodes)

ev = Evaluator()
bodies, id_to_node = ev.evaluate(nodes, root_scope)
for body in bodies:
    print(body.body.num_tri(), "triangles")

Development

uv sync --all-extras
uv run pytest

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

openscad_evaluator-1.0.0.tar.gz (272.9 kB view details)

Uploaded Source

Built Distribution

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

openscad_evaluator-1.0.0-py3-none-any.whl (273.6 kB view details)

Uploaded Python 3

File details

Details for the file openscad_evaluator-1.0.0.tar.gz.

File metadata

  • Download URL: openscad_evaluator-1.0.0.tar.gz
  • Upload date:
  • Size: 272.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for openscad_evaluator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 73b38775543c779614a680f904b09d77743217223e5768fe8739328dceef04a4
MD5 7ab628933fa44407ec40cd6755602d96
BLAKE2b-256 fbad1877e8cd6eb82290f0adeb3b33ce738cdb0ce13c4df2e9dc8556ce06f503

See more details on using hashes here.

Provenance

The following attestation bundles were made for openscad_evaluator-1.0.0.tar.gz:

Publisher: publish.yml on BelfrySCAD/openscad_evaluator

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

File details

Details for the file openscad_evaluator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openscad_evaluator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 236cd728964b2d468a4421646a0c9d0381ff6040abf62d54537af4194be91808
MD5 8295a6b20fb3b124d5e38608b25d2d1d
BLAKE2b-256 e5ab34b1960d7e55f3b57debf0d6a95b07174a0a6bc3887520e383874a872159

See more details on using hashes here.

Provenance

The following attestation bundles were made for openscad_evaluator-1.0.0-py3-none-any.whl:

Publisher: publish.yml on BelfrySCAD/openscad_evaluator

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