SolidAI is an autonomous, state-aware parametric CAD engineering agent that transforms natural language engineering prompts and 2D blueprints into native, parametric SOLIDWORKS 3D CAD models via the Windows COM API.
- π¬ Natural Language to 3D CAD: Convert mechanical design prompts ("Design a lightweight robot arm articulation link with weight-reduction pockets, mounting holes, and chamfers") into fully featured SOLIDWORKS models.
- π 2D Blueprint Vision to 3D CAD: Extract dimensions, datum faces, multi-view projections (Front, Top, Section), and tolerances from raster technical drawings (
.png,.jpg,.bmp) to reconstruct 3D geometry. - π Hybrid AI Architecture: Seamlessly switch between Google Gemini (Gemini 2.5 Flash / Pro) for advanced multi-view blueprint reasoning and Ollama / Qwen2.5-Coder for 100% offline local privacy.
- π‘οΈ 3-Stage Closed-Loop Self-Healing:
- Strict Pydantic Schema Validation: Structural syntax enforcement before execution.
- Headless Python CAD Simulator: Static collision, contour overlap, and centerline verification.
- Live State-Aware Error Recovery: If SOLIDWORKS returns a COM error or geometric anomaly, SolidAI intercepts the error code, reports feature state back to the LLM, and repairs the plan on a clean document.
- π§ͺ Headless CI/CD Testing Suite: Complete in-memory
MockCADEngineallowing full benchmark evaluation without requiring a SOLIDWORKS license or Windows COM runtime.
flowchart TD
User["User Prompt / 2D Blueprint"] --> GUI["Desktop UI (SolidAI_GUI.py)"]
GUI --> Coordinator["Agent Coordinator (cad_executor.py / vision_analyzer.py)"]
subgraph SG1 ["AI Engine Layer"]
Coordinator -->|Cloud Multi-View Reasoning| Gemini["Google Gemini (2.5 Flash / Pro)"]
Coordinator -->|Local Offline Mode| Ollama["Ollama (Qwen2.5-Coder)"]
end
subgraph SG2 ["Verification and Guardrails"]
Gemini --> Schema["1. Pydantic Schema Validation (cad_schema.py)"]
Ollama --> Schema
Schema --> Sim["2. Headless CAD Dry-Run Simulator (cad_simulator.py)"]
end
subgraph SG3 ["Execution and Live CAD Layer"]
Sim --> LiveEngine["3. SolidWorksCADEngine (cad_engine.py)"]
Sim -.->|Headless CI / Testing| MockEngine["MockCADEngine (mock_engine.py)"]
LiveEngine --> SW["SOLIDWORKS (Native Parametric 3D Model)"]
LiveEngine -.->|COM Error / Geometry Anomaly| Coordinator
end
- Operating System: Windows 10 / 11 (64-bit)
- CAD Environment: SOLIDWORKS 2024, 2025, or 2026 installed and activated
- Python: Python 3.10 or higher
- (Optional) Ollama: For 100% offline local model inference (ollama.com)
Clone the repository and install dependencies:
git clone https://github.com/YourUsername/SolidAI.git
cd SolidAI
pip install -r requirements.txtCopy the example configuration file:
cp config.example.json config.jsonEdit config.json (or enter your key directly inside the GUI):
{
"GEMINI_API_KEY": "YOUR_GEMINI_API_KEY_HERE"
}Security Note:
config.jsonis protected by.gitignoreand will never be committed to Git.
Ensure SOLIDWORKS is open, then launch the agent:
# Using the portable batch launcher
start_solidai.bat
# Or run directly with Python
python SolidAI_GUI.pySolidAI is designed with an intuitive dual-mode workflow that allows mechanical engineers and designers to move from concept to CAD in seconds.
- Launch the Application: Run
start_solidai.batorpython SolidAI_GUI.py. - Select AI Engine:
π Hybrid (Google Gemini): Cloud-connected reasoning with high dimensional precision and creative geometry optimization.π» Local (Ollama / Qwen2.5-Coder): Runs 100% locally on your machine with zero API cost and full data privacy.
- Select Design Style & Creativity:
ποΈ Aerospace & Racing: Automatically directs the AI to design lightweight parts featuring pocketing, weight-reduction cavities (draw_lightening_pocket), stiffening ribs (draw_stiffening_rib), and edge chamfers.π Industrial & Heavy-Duty: Generates rigid, thick-walled parts optimized for heavy machining, welding, or casting.π Minimalist & Standard: Constructs exact, direct geometric shapes matching standard geometric dimensions without decorative features.
- Enter Your Design Requirements:
- Type your mechanical requirements into the prompt box (e.g., "Design an L-bracket for a NEMA 17 motor with 31 mm mounting pattern, 22 mm center bore, and 4 mm wall thickness").
- Or click any of the Quick Engineering Templates at the bottom to pre-fill verified mechanical parts (flanges, shafts, brackets, drone frames, pillow blocks).
- Generate:
- Click
π Generate Parametric CAD in SOLIDWORKS. - SolidAI will synthesize the multi-step parametric action plan, execute a dry-run simulation, and stream the commands into SOLIDWORKS.
- Within seconds, your 3D model will appear centered and zoomed-to-fit on the SOLIDWORKS viewport!
- Click
- Switch to Tab 2: Click on the
π Blueprint to 3D CADtab at the top of the window. - Select Technical Drawing Image:
- Click
π Select Blueprint / Drawing (.png, .jpg, .bmp). - Choose a photo, scan, or raster image of an engineering drawing or blueprint.
- A thumbnail preview with dimensions and file size will appear on screen.
- Click
- Add Engineering Directives (Optional):
- In the notes text box, enter any specific instructions (e.g., "Ensure center bore has H7 tolerance, cut M10 tapped holes at corners").
- Enter Gemini API Key:
- Provide your Google Gemini API key in the password field (saved securely in your local session).
- Generate from Blueprint:
- Click
π Generate 3D CAD from Blueprint. - The Vision Specialist decomposes the drawing into Front, Top, and Section views, resolves dimensions, builds the parametric feature tree, and models the part in SOLIDWORKS.
- Click
If you prefer to run SolidAI without an internet connection or external API keys:
- Download and install Ollama from ollama.com.
- Pull the optimized coder model:
ollama pull qwen2.5-coder:7b
- SolidAI's
start_solidai.batwill automatically start the background Ollama service if it is not already running. - In the GUI, select
π» Local (Ollama / Qwen2.5-Coder)as the AI Engine.
-
SOLIDWORKS Connection Issues:
- Ensure SOLIDWORKS is running before clicking Generate. SolidAI connects via Windows COM (
win32com.client.Dispatch("SldWorks.Application")). - If you see a COM error, restart SOLIDWORKS and run
start_solidai.bat.
- Ensure SOLIDWORKS is running before clicking Generate. SolidAI connects via Windows COM (
-
What happens if a feature fails?:
- SolidAI features an automated Self-Healing Loop. If an extrusion or cut encounters a geometric collision or fails in SOLIDWORKS, SolidAI intercepts the exact COM error code and model state, feeds it back to the AI planner, and regenerates a repaired plan on a fresh part document.
-
Quota Limits on Free Gemini API:
- If a model reaches the free-tier rate limit (HTTP 429), SolidAI automatically falls back through its frontier candidate pool (
gemini-3-flash-preview$\rightarrow$ gemini-3.8-flash$\rightarrow$ gemini-3.7-flash$\rightarrow$ local Ollama) without crashing.
- If a model reaches the free-tier rate limit (HTTP 429), SolidAI automatically falls back through its frontier candidate pool (
SolidAI/
βββ SolidAI_GUI.py # Modern dark-themed Tkinter GUI (Dual Tab: Prompt & Blueprint)
βββ cad_engine.py # SolidWorksCADEngine: COM API wrapper, unit conversion, 2D/3D operations
βββ mock_engine.py # MockCADEngine: Pure-Python headless in-memory CAD engine for CI/testing
βββ cad_executor.py # Execution engine, streaming, closed-loop self-healing loop
βββ cad_schema.py # Pydantic schema validation & bilingual action mapping
βββ cad_simulator.py # Static dry-run simulator & contour overlap detector
βββ agent_prompt.py # Senior Mechanical Engineer system prompts & few-shot library
βββ vision_analyzer.py # Technical drawing blueprint vision analyzer & prompt compiler
βββ parametric_templates.py # Verified mathematical templates (flanges, shafts, brackets, frames)
βββ settings.py # Safe configuration manager for API keys & model endpoints
βββ start_solidai.bat # Portable launcher script (%~dp0)
βββ config.example.json # Sanitized configuration template
βββ requirements.txt # Python runtime dependencies
βββ LICENSE # MIT License
βββ ARCHITECTURE.md # In-depth architectural specification and API reference
βββ eval/ # Benchmark suite and automated evaluation tools
β βββ run_benchmark.py # Automated 9-case benchmark with fault injection tests
β βββ test_cases.json # Benchmark geometric specifications
βββ tools/ # Diagnostic and audit utilities
βββ audit_codebase.py # Signature verification and API consistency checker
βββ api_probe.py # Live Gemini and Ollama model endpoint tester
SolidAI features a built-in automated test suite measuring volumetric accuracy, body integrity, and fault injection defenses:
python eval/run_benchmark.py| Test Case | Description | Geometric Target | Status |
|---|---|---|---|
| CASE_1 | 6-Hole Standard Pipe Flange | Single solid body, 6x PCD holes | β PASS |
| CASE_2 | NEMA 17 Stepper Motor L-Bracket | Slotted base, 31 mm motor pattern | β PASS |
| CASE_3 | 3-Step Rotational Transmission Shaft | Multi-step concentric body, chamfers | β PASS |
| CASE_4 | Pillow Block Bearing Housing | Bottom slot, central bearing bore, rib | β PASS |
| CASE_5 | Stepped Bearing Block (M10 Threaded) | Tapped corner holes, cylindrical hub | β PASS |
| CASE_6 | Shift Fork & Clevis Linkage (Drawing 36) | Crescent fork body, pin hole, slot | β PASS |
| CASE_7 | Quadcopter 240 mm X-Frame Chassis | Diagonal arms, motor beds, slots | β PASS |
| FAULT_1 | Unknown Operation Injection | Caught by Pydantic schema | β PROTECTED |
| FAULT_2 | Empty Sketch Extrusion Injection | Caught by static CAD simulator | β PROTECTED |
| FAULT_3 | Revolve Without Centerline Injection | Caught by static CAD simulator | β PROTECTED |
SolidAI supports 36+ verified parametric operations including:
- Planes & Faces:
select_plane,select_face,select_top_face,select_face_by_ray,create_ref_plane,select_ref_plane - 2D Sketching:
draw_circle,draw_center_rectangle,draw_corner_rectangle,draw_rotated_rectangle,draw_polygon,draw_slot,draw_line_chain,draw_centerline,draw_circular_hole_pattern,draw_rectangular_hole_pattern - 3D Features:
extrude_boss,extrude_cut,revolve_boss,revolve_cut,apply_chamfer,apply_fillet,create_hole_wizard,circular_pattern_last_feature,shell_body
Full API documentation and coordinate transform details can be found in ARCHITECTURE.md.
Contributions are welcome! Please review CONTRIBUTING.md for pull request guidelines, coding standards, and testing procedures.
This project is licensed under the MIT License - see the LICENSE file for details.