๐Ÿงฉ Full Code Mechanical Design

A code-driven approach to mechanical design without relying on GUI-based CAD workflows.

Back to Portal (EN)

This repository explores a methodology for designing mechanical parts and assemblies
entirely through Python code using FreeCAD, focusing on:


Language GitHub Pages ๐ŸŒ GitHub ๐Ÿ’ป
๐Ÿ‡บ๐Ÿ‡ธ English GitHub Pages EN GitHub Repo EN

This repository explores a methodology for designing mechanical parts and assemblies
entirely through Python code using FreeCAD, focusing on reproducibility,
clarity of design intent, and automation.

๐Ÿ“Œ Persistent Identifier (DOI)
DOI


๐Ÿ“š Citation & Prior Art

This work is published with a DOI via Zenodo (10.5281/zenodo.18134920)
and constitutes prior art for code-driven mechanical design methodologies.


๐Ÿ•ฐ Historical Context

Prototype fabrication โ†’ machining โ†’ dimensional measurement โ†’ drawing.
Three-dimensional objects are projected onto two-dimensional drawings
using orthographic projection, and conversely, three-dimensional form
is reconstructed mentally from two-dimensional drawings.

This bidirectional translation constituted a core skill
for traditional mechanical designers.

From this perspective, it is understandable that
generative design or code-driven approachesโ€”where the designer
does not directly manipulate geometryโ€”can feel intuitively
difficult to accept.

However, semiconductor layout design followed a similar trajectory.

There was a time when routing was performed manually,
with designers carefully accounting for process-specific behavior
based on experience and tacit knowledge.

As design rules were formalized and incorporated into PDKs,
the center of design activity shifted
from manual layout to logical description using Verilog.

Viewed in the context of technological history,
it may be unavoidable that mechanical design
will follow a comparable path.


๐Ÿ† Why Full Code Mechanical Design Wins

Mechanical design should not be treated as a static artifact
(CAD data or drawings),
but as a reproducible, evolvable set of rules.

Full Code Mechanical Design shifts the core of mechanical design from
manual GUI operations to explicit, executable code.

In this approach:

This is not an efficiency improvement.
It is a structural transformation of mechanical design itself.

Once design logic is expressed as code,
there is no reason to return to GUI-driven workflows.


๐Ÿง  Concept

Traditional CAD workflows are heavily dependent on GUI operations,
feature histories, and constraint-based assemblies.

This project intentionally avoids those assumptions and adopts the following principles:

The goal is to preserve design intent and reproducibility directly in code.


โ“ Why Code-Driven Mechanical Design?

This approach can be summarized as:

Mechanical Design as Code


๐Ÿ“ Design Policy


๐Ÿ—‚ Repository Structure

โ”œโ”€ src/
โ”‚  โ”œโ”€ parts/        # Individual part generators (functions/modules)
โ”‚  โ”œโ”€ assembly/     # Assembly and layout definitions
โ”‚  โ””โ”€ build.py      # Entry point to generate the complete model
โ”œโ”€ README.md
โ””โ”€ LICENSE

โ–ถ Quick Start (Minimal Reproducible Example)

This repository includes a minimal working example that generates
a simple 3D mechanical model using FreeCAD in headless (non-GUI) mode.

๐Ÿ”ง Requirements

โš ๏ธ Important
Do NOT use system Python.
You must use the Python interpreter bundled with FreeCAD.


โ–ถ Execution (Windows example)

cd src
"C:\Program Files\FreeCAD 0.21\bin\FreeCADCmd.exe" build.py

This will:

The FreeCAD GUI is not required for model generation.
It may be used only to inspect the generated result.


โ–ถ Execution (Linux example)

cd src
freecadcmd build.py

๐ŸŽฏ Purpose of This Example

This example is intentionally minimal.

Its purpose is not to demonstrate complex geometry,
but to prove that:


๐Ÿšง Status

This repository currently focuses on defining the
conceptual and architectural principles
of Full Code Mechanical Design.

Python / FreeCAD implementation examples
will be added incrementally.


๐Ÿงญ Philosophy

CAD is not a drawing tool.
It is an engine for executing design logic.


๐Ÿงฑ Example Output

The following model was generated by running the provided Python code in FreeCAD
without any GUI-based modeling operations.

Code-generated mechanical assembly (FreeCAD + Python)

Figure 1. Mechanical assembly generated purely by Python code using FreeCAD as a geometry engine.


๐Ÿ“ Geometric Core Example (Function-Defined Geometry)

The following model demonstrates a purely geometric solid
generated from a continuous mathematical function,
without sketches, constraints, or GUI-based modeling steps.

Function-defined geometric solid generated purely by code

Figure 2. A geometric solid generated from an explicit radius function
$r = f(z)$ using Python code and FreeCAD as a geometry engine.


๐Ÿ“ Advanced Geometry Examples (Executable Design Intent)

๐ŸŒ€ Twisted Loft Solid โ€” Function-Defined, Code-Only Geometry

This example is generated by the following script:

The solid is created by lofting multiple cross-sections whose orientation is continuously rotated as a function of axial position.

No Sketch, no constraints, no PartDesign features are used.
All geometry is defined explicitly in Python and executed by FreeCAD as a geometry engine.

Twisted loft solid generated purely by Python code (FreeCAD)

Key characteristics:

\[\theta(z) = f(z)\]

This geometry has no feature history.
The only source of truth is the Python code itself.


๐ŸŒฟ Branched Spiral Sweep โ€” Branch-Aware Parametric Geometry

This example is generated by:

The model demonstrates a branched spiral sweep, where multiple spiral paths diverge from a common origin and are swept with a function-defined cross-section.

Such geometry is extremely difficult to author or modify in conventional GUI-based CAD systems, but becomes a natural consequence of code-defined logic.

Branched spiral sweep solid generated purely by Python code (FreeCAD)

Key characteristics:

Once geometry is expressed as code,
branching is not a special case โ€” it is just control flow.


๐Ÿง  Why These Screenshots Matter

These figures are not mere visual examples.

They serve as:

The generated CAD files are artifacts.
The design itself lives in code.


๐Ÿงฉ Design Pattern Summary

Script Geometry Type Core Idea
loft_twist.py Twisted loft solid Continuous function-defined orientation
branched_spiral.py Branched sweep solid Branch-aware parametric path logic

These scripts demonstrate that mechanical geometry can be treated as an executable system, not a manually authored shape.


๐Ÿ”Œ Analogy to SoC Design

This approach is directly analogous to modern SoC design workflows.

In this sense:

Full Code Mechanical Design is to mechanical engineering
what RTL is to SoC design.


๐Ÿ’Ž Beyond CAD: Mechanical Design as IP

By expressing geometry, constraints, and design decisions
entirely in code, mechanical design itself becomes
a reusable and evolvable intellectual property (IP).

The generated CAD model is only a byproduct.
The true asset is the executable design knowledge.


๐Ÿ” Practical Workflow Comparison

Conventional Mechanical Design vs Full Code Mechanical Design

Aspect Conventional Workflow Full Code Mechanical Design
Design authoring GUI-based CAD operations Python code
Dimensions Fixed Variables
Design intent Implicit Explicit
Design change Manual edits Logic change
Reusability Low High
Review Drawings Code + model
Scalability Limited High

๐Ÿ‘ค Author

๐Ÿ“Œ Item Details
Name Shinichi Samizo
Expertise Semiconductor devices (logic, memory, high-voltage mixed-signal)
Thin-film piezo actuators for inkjet systems
Printhead productization, BOM management, ISO training
GitHub GitHub

๐Ÿ“„ License

Hybrid License

Item License Description
Source Code Apache License 2.0 Free to use, modify, redistribute, with patent protection
Text Materials CC BY 4.0 Attribution required
Figures & Diagrams CC BY-NC 4.0 Non-commercial use only
Generated CAD Outputs Same as source code Derived from licensed code
External References Original license applies Cite properly

Methodology Notice

This repository discloses a code-driven mechanical design methodology. The methodology itself is provided as prior art and may not be claimed as exclusive intellectual property by third parties.

Prior Art Notice

This repository and its associated Zenodo record (DOI: 10.5281/zenodo.18134920) constitute a public disclosure of the Full Code Mechanical Design methodology.


๐Ÿ’ฌใ€€Feedback

Suggestions, improvements, and discussions are welcome via GitHub Discussions.

๐Ÿ’ฌ GitHub Discussions