Where Is the cadgen Package Located in the text-to-cad Repository
The cadgen package resides in the packages/cadgen directory, with its Python source code rooted at packages/cadgen/src/cadgen/ within the earthtojake/text-to-cad monorepo.
The cadgen library powers all CAD-generation workflows in the text-to-cad project, including STEP/STL export, assembly construction, and the CAD Viewer backend. Locating the package source is critical for developers extending the build123d integration or debugging geometry pipelines. This guide maps the exact file paths, entry points, and module organization as implemented in the repository source.
cadgen Package Directory Structure
The package follows a standard Python src-layout nested within the repository's packages directory:
packages/cadgen/
├── pyproject.toml
└── src/
└── cadgen/
├── __init__.py
├── assembly.py
├── build123d.py
├── glb.py
├── step.py
├── stl.py
└── viewer/
└── http_app.py
The distributable library code lives entirely under packages/cadgen/src/cadgen/. This path contains the __init__.py entry point that lazily re-exports public symbols including step, stl, glb, AssemblyHelper, and build123d utilities.
Key Source Files and Their Functions
Understanding the internal module layout helps navigate the codebase efficiently:
-
packages/cadgen/src/cadgen/__init__.py— Package bootstrap and version resolution. This file implements lazy re-export logic for all public APIs and reads version metadata from the project'spyproject.tomlwhen running from a source checkout. -
packages/cadgen/src/cadgen/step.py— Core STEP generation utilities for exporting CAD geometry to the ISO 10303 standard format. -
packages/cadgen/src/cadgen/stl.py— STL export helpers for tessellated mesh generation. -
packages/cadgen/src/cadgen/glb.py— GLB (binary glTF) generation for web-based 3D visualization. -
packages/cadgen/src/cadgen/assembly.py— Assembly construction helpers includingAssemblyHelperandMateTargetclasses for positioning parts relative to each other. -
packages/cadgen/src/cadgen/viewer/http_app.py— HTTP server implementation that powers the CAD Viewer backend UI. -
packages/cadgen/src/cadgen/daemon/server.py— Background processing daemon for handling asynchronous CAD generation tasks.
Importing and Using cadgen from Source
Once located in the filesystem, you can import cadgen directly from the repository. The package uses absolute imports rooted at the src/ directory.
Basic Assembly and Export
import cadgen
# Create a simple assembly
asm = cadgen.AssemblyHelper()
cube = cadgen.stl.cube(size=10)
asm.add(cube)
# Export to STEP format
cadgen.step.write_step(asm, "example.step")
Launching the CAD Viewer Backend
from cadgen.viewer import http_app
# Start the viewer HTTP server on localhost:8080
http_app.run(host="127.0.0.1", port=8080)
Accessing Package Version
from cadgen import __version__
print(f"cadgen version: {__version__}")
The version resolution logic in packages/cadgen/src/cadgen/__init__.py automatically detects whether the package is installed or running from a source checkout, falling back to pyproject.toml metadata when necessary.
Integration with the Monorepo
The cadgen package is referenced by other components in the earthtojake/text-to-cad repository through the monorepo's dependency configuration. The pyproject.toml file at packages/cadgen/pyproject.toml defines package metadata, entry points, and version information used by the build system. When the repository's skills or test suites import cadgen, they resolve to this specific location under packages/cadgen/src/.
Summary
- The cadgen package location is
packages/cadgen/at the repository root, with source code inpackages/cadgen/src/cadgen/. - The entry point
__init__.pyhandles lazy re-exports and version resolution frompyproject.toml. - Core modules include
step.py,stl.py,glb.py, andassembly.pyfor geometry operations. - The viewer backend lives in
viewer/http_app.pyand the daemon indaemon/server.py. - Import paths resolve from the
src/directory using standard Python package mechanics.
Frequently Asked Questions
What is the exact file path for the cadgen package entry point?
The main entry point is located at packages/cadgen/src/cadgen/__init__.py. This file initializes the package namespace, implements lazy re-export logic for public symbols like AssemblyHelper and step, and contains version-resolution logic that reads from pyproject.toml during source checkouts.
How do I import cadgen when working from the text-to-cad source repository?
When working from the repository root, Python resolves imports from the packages/cadgen/src/ directory. You can use import cadgen or specific imports like from cadgen.viewer import http_app provided your Python path includes the src/ directory or the package is installed in editable mode.
Where is the CAD Viewer backend code located within cadgen?
The HTTP server powering the CAD Viewer UI is located at packages/cadgen/src/cadgen/viewer/http_app.py. This module contains the http_app object with the run() method used to launch the local development server on a specified host and port.
Which file handles STEP export functionality in the cadgen package?
STEP generation utilities are implemented in packages/cadgen/src/cadgen/step.py. This module provides the write_step() function and related helpers for exporting CAD geometry to the STEP file format used in manufacturing workflows.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →