This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Dependencies: Uses Pipenv for dependency management
pipenv install- Install dependenciespipenv shell- Activate virtual environment- Python 3.13 is required (see Pipfile)
- Main entry point:
python 3dm.pyor./3dm.py(executable Python script) - Common commands:
python 3dm.py setup- Initial configuration setuppython 3dm.py new- Create new 3DMake projectpython 3dm.py build- Build OpenSCAD model to STLpython 3dm.py build slice- Build and slice to GCODEpython 3dm.py build slice print- Full pipeline to printingpython 3dm.py help- Show all available actions
- No formal test suite is present in the main codebase
- Testing appears to be manual through the CLI interface
- Sample projects exist in
troys_local_sample_poject/for testing
- Avoid obvious comments that merely restate what the code does
- Only add comments when they explain why something is done or provide non-obvious context
- Examples of comments to avoid:
# Load existing cache if it exists(obvious from the code)# Check if we need to fetch(obvious from the conditional)# Update cache with new timestamp(obvious from the assignment)
- Prefer clear variable names and simple code structure over explanatory comments
- Docstrings should be concise and focus on the function's purpose, not implementation details
3DMake follows a command-action pipeline architecture where:
- Commands are parsed from CLI arguments into "verbs" (actions)
- Actions can imply other actions (e.g.,
printimpliesslice) - Actions run in sequence, passing a shared
Contextobject - Each action can be either
isolated(runs alone) orpipeline(part of a workflow)
- Parses command-line arguments using argparse
- Loads configuration from TOML files (global
defaults.toml+ project3dmake.toml) - Builds a
Contextobject with options, file paths, and config directory - Executes actions in sequence from
ALL_ACTIONS_IN_ORDER
- Context: Shared state object containing config, file paths, and intermediate results
- Action: Dataclass defining action metadata and implementation
- Decorators:
@isolated_action: Actions that run alone (setup, help, version)@pipeline_action: Actions that are part of build/print workflows@internal_action: Internal steps that don't show user output
- CommandOptions: Configuration settings merged from defaults.toml, 3dmake.toml, and CLI args
- FileSet: Tracks input files and outputs through the pipeline (scad → stl → oriented_stl → gcode)
- MeshMetrics: 3D mesh analysis data (bounding box, dimensions)
Actions are organized by functionality:
- Project management:
new_action.py,edit_actions.py - Build pipeline:
build_action.py,measure_action.py,orient_action.py,slice_action.py - Output:
preview_action.py,image_action.py,print_action.py - Information:
info_action.py,list_config_actions.py,help_action.py - Setup:
setup_action.py,library_actions.py
openscad.py: OpenSCAD integration and STL generationrenderer.py: 3D model rendering for images and analysisprint_config.py: PrusaSlicer configuration managementftp.py: Bambu Labs printer FTP integrationprompts.py: CLI interaction utilitiesstream_wrappers.py: Output formatting and indentation
- Global config:
~/.config/3dmake/defaults.toml(via platformdirs) - Project config:
./3dmake.tomlin project directory - Printer profiles:
~/.config/3dmake/profiles/(PrusaSlicer INI format) - Overlays:
~/.config/3dmake/overlays/(setting modifications) - Settings cascade: defaults.toml → 3dmake.toml → CLI arguments
- Input: OpenSCAD
.scadfiles or STL files - Build: OpenSCAD → STL conversion
- Measure: Extract mesh metrics (dimensions, bounds)
- Orient: Auto-orient for optimal printing (optional)
- Preview: Generate 2D "silhouette" previews (optional)
- Slice: PrusaSlicer integration for GCODE generation
- Print: Send to OctoPrint or Bambu Labs printers
- OpenSCAD: 3D modeling (bundled in
deps/for Windows) - PrusaSlicer: Slicing engine (bundled in
deps/for Windows) - VTK/vtkplotlib: 3D mesh processing and rendering
- Tweaker3: Auto-orientation algorithm
- Google Generative AI: Model description via image analysis
- paho-mqtt: Bambu Labs printer communication
- Action Pipeline: Sequential execution of configurable actions
- Context Passing: Shared state object passed between all actions
- Decorator-based Registration: Actions self-register using decorators
- File State Tracking: FileSet tracks intermediate outputs through pipeline
- Configuration Layering: Multiple TOML files with override precedence
- Cross-platform Bundling: External tools bundled in
deps/directory