How vilemduha/blendercam works
Project Type and Main Purpose
• Project Type: A Blender add-on (a plugin) that adds CAM capabilities.
• Purpose: It provides users with artistic, personal, or industrial CNC milling guidance by generating toolpaths and g-code, simulating milling operations, and incorporating various post-processors.
Main Components
a. Blender Environment & Integration:
– Represent Blender as the host environment.
– Show “config” files (startup.blend, userpref.blend) and “Examples” that demonstrate how the add-on is loaded and used.
– Include the add-on’s integration points with Blender’s UI (panels, menus, pie menus) which are implemented in the “scripts/addons/cam/ui/” and “scripts/addons/cam/ui/panels” directories.
b. Core CAM Engine:
– Point out that it uses several modules from “scripts/addons/cam” such as “bas_relief.py”, “collision.py”, and “gcode_import_parser.py”.
– Include “utilities” submodule for geometry, machine, and material utilities (files in “scripts/addons/cam/utilities/”) which support the core algorithms.
c. Operations & Operators:
– Represent a block for Operator Modules (scripts/addons/cam/operators) that implement various cutting operations such as pocketing, slicing, pattern creation, and more.
– Indicate that these modules serve as the interface between user actions (from Blender’s UI) and the CAM engine.
d. Presets and Configuration:
– Show a section for “Presets” which contain cutter definitions, machine setups, and predefined operations (located under “scripts/addons/cam/presets”).
– This part lets users quickly load specific settings for different milling setups.
e. Post-Processors:
– Create a dedicated block for Post-Processors (found in “scripts/addons/cam/post_processors”), which are responsible for converting the CAM engine’s output into machine-specific g-code.
– Label several of the supported post-processors used for GRBL, LinuxCNC/EMC2, Fadal, and others.
f. Testing and CI/CD:
– Include a block for the “tests” folder (scripts/addons/cam/tests) that holds developer tests and test data, ensuring the functionality is continuously validated.
– Optionally, include a note on the GitHub workflows (.github/workflows) which automate building, testing, documentation generation, and release management.
Relationships and Data Flow
• UI events call the CAM Engine (business logic) which processes geometry and simulates the toolpath generation.
• The CAM Engine then hands off data to the Post-Processors for generating g-code.
• Presets and user preferences provide configuration inputs to the CAM engine.
• Testing and CI workflows support the entire codebase, ensuring quality and integration.
Architectural Patterns and Design Principles
• Modular structure: separation of UI components, core processing routines, utility libraries, and post-processing modules.
• That the add-on leverages the Model-View-Controller (MVC) concept – where the “model” represents the CAM engine and data structures; the “view” is implemented via Blender’s UI panels and menus; and the “controller” is distributed among the operator modules.
• Extensibility: the clear separation of post-processors and presets makes it simple to add support for new machines or operations.
Technologies, Frameworks, and Libraries
• Python is the primary language.
• Integration with Blender’s Python API.
• External libraries referenced through the “wheels” folder (e.g., OpenCAMLib, Shapely, and any numba/ocl utilities) that assist with computational geometry and performance enhancements.
• CI/CD workflows on GitHub integrate tools like Black (code formatter) for maintaining code quality.