Multi-Agent-CAD

Pan-CheraMIT活跃维护

把文本生成 CAD 模型拆成多个智能体协作完成,通过约束式测试时计算提升生成质量,适合机械设计与 3D 打印场景。

MAC (Multi-Agent CAD): A decoupled multi-agent framework for text-to-CAD generation via constrained test-time compute

v1.0.0发布于 2026-09-24 12:18 UTC1,075star +3 / 7 天100fork同步于 2026-11-10 17:53 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/Pan-Chera/Multi-Agent-CAD.git
cd Multi-Agent-CAD
conda env create -f environment.yml
conda activate multi_agent_cad
pip install --no-deps "aider-chat==0.82.3"
export DASHSCOPE_API_KEY="your-key"
硬件要求按 README 说明

README 未说明显存或 GPU 要求;依赖 build123d/OCP 做几何运算,主要调用云端 OpenAI 兼容接口(默认 DashScope),未提及本地模型推理。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用自然语言生成可编辑 CAD 零件与装配体,并输出 STEP/STL/GLB/URDF 的多智能体框架

把文本生成 CAD 模型拆成多个智能体协作完成,通过约束式测试时计算提升生成质量,适合机械设计与 3D 打印场景。

核心能力

  • 多智能体解耦流程,分阶段完成规划、零件生成与修复
  • 内置独立 Judge 与视觉+几何双重校验
  • 支持多零件装配分解、关节接口与重复件复用
  • 导出 STEP/STL/GLB,装配体可导出 URDF 供仿真
  • 提供浏览器 Web UI 与单零件命令行工作流

容易踩的坑

aider-chat 锁定 NumPy 1.x 与 build123d 的 NumPy 2.x 冲突,必须用 --no-deps 单独安装;build123d 需限制在 <0.13,0.13 换用 OCP 8 无法加载当前 STEP 运行时;Web UI 默认只监听 127.0.0.1 且会以本机权限执行生成的 Python,不要暴露到不可信网络。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

2 个版本v1.0.0
  1. v1.0.0Release v1.0.0最新正式版2026-09-24 · 2026-09-24 12:18 UTC

    Release v1.0.0

    Highlights

    This release ships three batches of targeted hardening on the existing feature/assembly line, plus operator-facing documentation:

    • CAD generation hardening — deterministic coder path resolution, last-fenced-block JSON extraction, and read-only Aider reference file.
    • Assembly validation improvements — under-connected mate-graph rejection, zero-volume mesh QA, and URDF preflight.
    • Web security improvements — CSRF defense, endpoint validation, artifact destination restrictions, and subprocess environment hardening.

    No public API contracts were renamed. No new dependencies were added.

    Bug Fixes

    • Builder registry — registered bent_jaw_xz (registry 28 → 29); mac_assembly/README.md builder-count reference updated.
    • Deterministic coder failures — _node_python_coder_deterministic now resolves the temp_design_*.py / temp_output_*.step / temp_output_*.stl paths before the code-generation attempt, so a generation failure reports a concrete script path instead of NameError.
    • JSON extraction — _extract_json_from_llm now takes the last fenced json block when an LLM emits multiple (was first), matching _extract_code_from_llm_response semantics. Fixes a class of silent parse failures when the LLM emitted an example block before the real answer.
    • Mating validation — connectivity / single-root / acyclicity checks now gate on n_graph > 1 (was plan.mates), so empty-mate multi-part briefs no longer silently pass. Added necessary-condition edge-count check (len(plan.mates) >= n_graph - 1); under-connected mate graphs now fail validation with a clear error.
    • Collision handling — _pair_collides in mac_assembly/assembly_qa.py now returns UNVERIFIABLE for zero-volume and non-finite-volume mesh pairs instead of false-passing on flat plates, sheet metal, single-triangle STLs, and NaN/inf volumes.
    • URDF validation — export_urdf runs a zero-volume mesh preflight before emitting any link; zero-volume links are rejected with a clear error instead of silently emitting a URDF with wrong dynamics that PyBullet/MuJoCo then reject downstream.

    Security

    This release closes four tracked security issues (BUG-010, BUG-011, BUG-012, BUG-020):

    • CSRF protection — every state-changing request (POST/PUT/PATCH/DELETE) now requires an X-MAC-CSRF: 1 header. The browser frontend sends it automatically; non-browser clients must add it manually or receive 403. Layered with loopback Host allowlist (when MAC_WEB_HOST is loopback), Origin validation, and Sec-Fetch-Site: cross-site rejection. DNS-rebinding-safe.
    • Endpoint validation — DS_BASE_URL is validated server-side before spawning a job. Scheme must be http or https (always enforced). Host must match the provider allowlist (loopback, api.openai.com, api.deepseek.com, generativelanguage.googleapis.com, .aliyuncs.com, .googleapis.com) unless MAC_WEB_ALLOW_CUSTOM_ENDPOINT=1 is set. The operator's real DashScope key is not forwarded via the LLM-client path.
    • Artifact destination restrictions — MAC_WEB_ALLOW_DEST_PATH=1 now also requires MAC_WEB_DEST_ROOT (absolute path); dest_path must be relative and resolve under root. Absolute dest_path and .. traversal are rejected. _copy_artifacts re-checks containment at write time as defense-in-depth.
    • Subprocess environment hardening — both subprocess.run sites that execute LLM-authored Python now pass an explicit env= built from a minimal allowlist (PATH, HOME, TMPDIR, TMP, TEMP, LANG, LC_ALL, LC_CTYPE, PYTHONPATH, PYTHONIOENCODING, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH) plus ITERATION set per child. Every provider key in the threat model (DASHSCOPE_API_KEY, OPENAI_API_KEY, OPENAI_API_BASE, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, MAC_CONFIG_FILE, etc.)
  2. ui-demo-v1Web UI walkthrough video2026-08-04 · 2026-08-04 09:35 UTC
    查看更新说明

    Hosted as release asset for README embedding — bypasses LFS / user-attachment size limits. Used in tag in README.md / README_cn.md.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    MAC — Multi-Agent CAD for Parts and Assemblies from Natural Language

    Tsinghua University, College AI, IEI Lab

    简体中文

    License: MIT Python 3.11+ Powered by build123d Outputs Assembly export

    MAC turns an ordinary design brief into editable engineering geometry. It can generate a single printable part or decompose a mechanism into separately generated components, assemble them, validate the result, and export the artifacts needed for downstream inspection and simulation workflows.

    MAC was originally released as a single-part Text-to-CAD workflow and has since received nearly 1,000 GitHub stars. This release preserves that workflow while adding visual verification, an independent Judge, and experimental multi-part assembly generation.

    MAC Web UI walkthrough

    Assembly Gallery (Technology Preview)

    Building on the original single-part workflow, MAC v2 introduces experimental natural-language assembly generation. The examples below are curated outputs, not a measured prompt-success rate, and the assembly workflow is not presented as outperforming CAD-agent skills. Validate generated geometry and joints before manufacturing or simulation use.

    Complex assemblies

    Three-Axis Gantry Metrology CellTelescopic Cinema Robot Crane
    A bridge-style inspection platform with three orthogonal motion stages.A multi-stage crane with an articulated support and telescopic payload arm.
    Three-axis gantry metrology cellTelescopic cinema robot crane
    Heavy-Duty Mobile ManipulatorAdvanced Vision Inspection Robot Arm
    A mobile base carrying a visually detailed articulated manipulator.A multi-joint inspection arm with a framed vision payload.
    Heavy-duty mobile manipulatorAdvanced vision inspection robot arm

    Complex-gallery generation usage

    AssemblyPlanning & matingPart generation & repairJudge & other workflowTotal tokensEstimated cost
    Three-Axis Gantry Metrology Cellabout 178,000461,811260,157about 900,000about $2
    Telescopic Cinema Robot Crane535,407663,427about 451,000about 1,650,000about $3
    Heavy-Duty Mobile Manipulatorabout 520,0002,678,0052,602,142about 5,800,000about $13
    Advanced Vision Inspection Robot Arm85,016160,367about 55,000about 300,000about $1

    Compact functional assemblies

    Hinged Twin-Claw GripperGuided Linear PlungerRotary Fork-Key ToolReusable Five-Digit Hand
    Hinged twin-claw gripperGuided linear plungerRotary fork-key toolReusable five-digit hand

    These curated compact examples exercise natural-language decomposition, joint interfaces, repeated-part reuse, and mirrored geometry. The complex gallery shows how the same workflow scales to larger visual assemblies. See the assembly workflow documentation for implementation details and current limitations.

    URDF Simulation

    The assembly workflow can export generated mechanisms as URDF files for downstream robotics and physics simulation. The demonstrations below use an AI-generated hand assembly to execute object rotation and pick-and-place tasks in simulation.

    Object RotationPick and Place
    AI-generated hand rotating an object in simulationAI-generated hand performing pick and place in simulation

    Part Gallery

    MAC also generates standalone mechanical and creative parts. The examples below are editable CAD results, not image-only generations.

    Honeycomb OrganizerGyroscope OrnamentLighthouseSmartphone StandBall-in-Cage
    Honeycomb organizerGyroscope ornamentLighthouseSmartphone standBall-in-cage
    Articulable GyroscopeMulti-Link ChainGeneva MechanismPlasma ReactorBrake Disc
    Articulable gyroscopeMulti-link chainGeneva mechanismPlasma reactorBrake disc

    The single-part workflow documentation covers configuration, execution, caching, and QA. Benchmark prompts and per-model data are linked from its benchmark-details section.

    Real-World Results

    3D-printed MAC models

    The printed collection above includes benchmark parts and original showcase models generated by the single-part workflow. MAC can also produce print-in-place mechanisms containing separate bodies and functional clearances:

    Single-Part Benchmark

    The following numbers apply specifically to the documented ten-prompt, 141-feature single-part-workflow benchmark. They are not assembly success-rate or assembly-cost claims.

    WorkflowModelIn-loop verificationTokensEstimated costFeature pass rate
    CAD Skill reproductionQwen 3.7—103.95M$18.59138/141 (97.9%)
    CAD Skill reproductionQwen 3.8Visual87.46M$29.45132/141 (93.6%)
    MAC v1Qwen 3.7Geometric0.90M$1.43140/141 (99.3%)
    MAC v2Qwen 3.8Visual + geometric1.40M$4.85140/141 (99.3%)

    Under the Qwen 3.7 setup, MAC v1 used 116× fewer recorded tokens and had a 13× lower estimated cost than the reproduced Skill baseline. Under Qwen 3.8 with visual verification, MAC v2 used 62.7× fewer recorded tokens and had a 6.1× lower estimated cost.

    MAC v1 refers to the original single-part workflow and its published benchmark run. MAC v2 refers to the updated single-part workflow with visual verification and the independent Judge. Assembly generation is presented separately as a technology preview and is not included in these benchmark figures.

    Across the two documented model configurations, MAC retained a 140/141 feature pass rate while using substantially fewer recorded tokens and lower estimated cost than the corresponding reproduced Skill runs.

    Methodology and raw breakdowns: single-part README, English evaluation, and Chinese evaluation.

    Why MAC?

    • Natural-language input — describe geometry, dimensions, interfaces, and motion without writing CAD code or an internal schema.
    • Parts and assemblies — use one project for standalone printable parts and articulated, multi-component mechanisms.
    • Editable engineering outputs — export STEP, STL, and GLB rather than a render-only result; assemblies also provide a URDF handoff.
    • Auditable generation — inspect structured briefs, geometry plans, generated Python, measurements, QA reports, and repair history.
    • Automatic execution and repair — generated CAD is executed and checked, with bounded feedback loops for recoverable failures.
    • Reuse instead of regeneration — repeated and mirrored components can be derived from one source geometry.
    • Model-flexible stages — configure different OpenAI-compatible models for planning, geometry, coding, and repair.
    • Visual workflow — the single-part pipeline includes a browser UI with 3D preview and downloadable results.
    • Built on a proven workflow — MAC v2 extends the original nearly 1,000-star single-part pipeline with visual verification and assembly generation while retaining the existing part-generation workflow.

    Quick Start

    Install

    git clone https://github.com/Pan-Chera/Multi-Agent-CAD.git
    cd Multi-Agent-CAD
    conda env create -f environment.yml
    conda activate multi_agent_cad
    pip install --no-deps "aider-chat==0.82.3"
    export DASHSCOPE_API_KEY="your-key"
    

    The final pip install is needed because aider-chat pins NumPy 1.x, which conflicts with build123d's NumPy 2.x requirement. It is therefore omitted from environment.yml; --no-deps avoids replacing the working NumPy version.

    The default configuration targets an OpenAI-compatible DashScope endpoint. Other providers are covered in the single-part configuration guide.

    The bundled cadpy runtime currently requires OCP 7.x, so installation constrains build123d to <0.13. Version 0.13 switches to OCP 8 and cannot load the current STEP runtime. If an existing environment has already upgraded, run python -m pip install "build123d>=0.8,<0.13" to restore compatible dependencies.

    pip users (no conda): aider-chat pins numpy==1.26.4, but build123d>=0.8 requires numpy>=2,<3 — these conflict in pure pip. Use this workaround (verified on macOS arm64 + Python 3.11):

    python3.11 -m venv .venv
    source .venv/bin/activate          # Windows PowerShell: .venv\Scripts\activate
    pip install --upgrade pip
    # Install aider first (pulls numpy 1.26.4 + transitive deps), then force-upgrade numpy.
    # Verified: aider 0.82.3 imports cleanly on numpy 2.x — the pin is over-cautious upstream.
    pip install "aider-chat==0.82.3"
    pip install --no-deps --force-reinstall "numpy>=2,<2.3"
    pip install "build123d>=0.8,<0.13" "langgraph>=0.2,<0.3" "langgraph-checkpoint>=2.0,<3.0" \
                "pydantic>=2.5" "openai>=1.20.0" "anthropic>=0.30" \
                "trimesh>=4.0" "rtree>=1.1" "scipy>=1.10" "scikit-learn>=1.3" \
                "fastapi>=0.110" "uvicorn[standard]>=0.27" "ipython>=8.15" "pytest>=7.4"
    # --no-deps skips re-checking the numpy pin in pyproject.toml; fastapi+uvicorn
    # are already installed by the previous step, so the [web] extras resolve.
    pip install --no-deps -e .
    

    The last step registers the mac-config-reset console script and lets you run python -m multi_agent_cad.graph from any directory. See requirements.txt / pyproject.toml for the canonical dependency list.

    Windows: the same conda env create + pip install --no-deps aider-chat==0.82.3 flow works — trimesh and rtree come from conda-forge prebuilt; OCP is pulled in transitively by build123d (via its PyPI dep cadquery-ocp-novtk). Don't use the pure-pip workaround below on Windows — native wheels for trimesh/rtree can be unreliable. Set the API key in PowerShell as $env:DASHSCOPE_API_KEY = "sk-..." (or set DASHSCOPE_API_KEY=sk-... in cmd.exe). For the Web UI under conda, pip install -e ".[web]" inside the activated env works — uvloop auto-skips on Windows. CI covers Windows with Python 3.11 and Linux with Python 3.11/3.12, including an isolated wheel installation check.

    Generate one part

    Set USER_REQUEST in multi_agent_cad/config.py, then run:

    python -m multi_agent_cad.graph
    

    For the single-part browser UI:

    pip install -e ".[web]"
    python -m multi_agent_cad.web
    

    The provider selector includes OpenRouter (https://openrouter.ai/api/v1). Switching presets fills suggested stage and Aider model names; models you have edited manually are preserved. Existing endpoint and model settings are loaded from config.py when the page opens. For OpenRouter, Aider uses an OpenAI-compatible model name such as openai/qwen/qwen3-max.

    If the key field is blank, the Web UI uses the server's DASHSCOPE_API_KEY, then DS_API_KEY from config.py. Explicit form keys take priority; API clients can also supply the existing config.DS_API_KEY request field. Server keys are never included in the configuration schema response or written to job config files. Use a key for the selected provider.

    The UI listens on 127.0.0.1 by default. It executes generated Python with your user account's permissions, so do not expose it directly to an untrusted network. Copying results to an arbitrary local directory is disabled unless MAC_WEB_ALLOW_DEST_PATH=1 is explicitly set.

    Web UI security and environment variables

    State-changing API endpoints (POST, PUT, PATCH, DELETE) require a custom X-MAC-CSRF: 1 header. The browser frontend sends it automatically; non-browser clients (curl, HTTP libraries) must add it manually or the server returns 403:

    curl -X POST http://127.0.0.1:8000/api/run \
      -H "X-MAC-CSRF: 1" \
      -H "Content-Type: application/json" \
      -d '{"prompt": "a 30 mm cube", "api_key": "YOUR_API_KEY"}'
    

    GET endpoints (/api/health, /api/jobs, status polling) are unaffected.

    The following environment variables control Web UI behavior:

    • MAC_WEB_HOST — bind address. Loopback values (127.0.0.1, localhost, ::1, the default) also enable a loopback Host allowlist as a defense-in-depth CSRF layer. Binding to a non-loopback address (LAN deployment) disables that layer; the X-MAC-CSRF header remains required.
    • MAC_WEB_ALLOW_CUSTOM_ENDPOINT=1 — opt in to non-loopback OpenAI-compatible DS_BASE_URL hosts: vLLM on a private hostname, a corporate gateway, or Ollama / LM Studio on a non-loopback address. Default off; otherwise the host must match the provider allowlist (loopback, api.openai.com, api.deepseek.com, openrouter.ai, generativelanguage.googleapis.com, .aliyuncs.com, .googleapis.com). Scheme (http/https) is always enforced.
    • MAC_WEB_ALLOW_DEST_PATH=1 — opt in to the dest_path artifact-copy feature. When set, MAC_WEB_DEST_ROOT must also be set to an absolute directory, and each request's dest_path must be relative and resolve under that root. Absolute dest_path and .. traversal are rejected.
    • MAC_CHILD_ENV_ALLOW=VAR1,VAR2 — pass additional non-secret environment variables through to the generated-Python subprocess (for example, HTTP_PROXY,HTTPS_PROXY on a corporate network). The default allowlist is PATH, HOME, TMPDIR, TMP, TEMP, LANG, LC_ALL, LC_CTYPE, PYTHONPATH, PYTHONIOENCODING, LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, SYSTEMROOT, WINDIR, plus ITERATION set per child. This applies to deterministic / Aider-assisted cadpy generation as well as the LLM fallback and repair runners. Never list API keys or credentials here — env-var stripping reduces secret leakage but does not sandbox the subprocess; see SECURITY.md.

    Generated CAD execution, including the cadpy runner, uses CAD_SCRIPT_TIMEOUT from multi_agent_cad/config.py. Increase it for models whose geometry or export needs more time; execution failures continue through the existing repair flow.

    Generate an assembly

    Assembly input is also ordinary natural language. Run an included request:

    MAC_ASSEMBLY_REQUEST="$(cat mac_assembly/assembly_prompts/natural_language_benchmarks/01_hinged_twin_claw_gripper.md)" \
    python -m mac_assembly
    

    Or provide a brief directly:

    MAC_ASSEMBLY_REQUEST="Create a two-part hinged clamp with a fixed base and one rotating jaw." \
    python -m mac_assembly
    

    Assembly jobs are written under assembly_jobs/job_<timestamp>/, including separate-part geometry, assembled STEP/STL/GLB, URDF, manifests, and QA artifacts. See the assembly guide before relying on an output for manufacturing or simulation.

    Documentation

    Citation

    If you find this project useful for your research, please consider citing:

    @misc{mac2026,
      author       = {Guanxing Qu and Xueyan Zou},
      title        = {MAC (Multi-Agent CAD): A Decoupled Multi-Agent Framework for Text-to-CAD Generation},
      year         = {2026},
      publisher    = {GitHub},
      journal      = {GitHub repository},
      howpublished = {\url{https://github.com/Pan-Chera/Multi-Agent-CAD}}
    }
    

    The quantitative single-part evaluation uses earthtojake/text-to-cad (CAD Skills) as the comparison baseline. If you cite the benchmark comparison, please also cite that project:

    @misc{texttocad2026,
      author       = {earthtojake},
      title        = {CAD Skills: A skills library for CAD, robotics, and hardware design agents},
      year         = {2026},
      publisher    = {GitHub},
      journal      = {GitHub repository},
      howpublished = {\url{https://github.com/earthtojake/text-to-cad}}
    }
    

    License

    MIT — see LICENSE.

    The vendored packages/cadpy STEP/GLB runtime is derived from earthtojake/text-to-cad (CAD Skills) and is redistributed under its original MIT license — see packages/cadpy/LICENSE.

    Acknowledgements

    • Tsinghua University, IEI Lab — the lab where this project was developed; provided the research environment and advisor guidance.
    • earthtojake/text-to-cad (CAD Skills) — source of the comparison baseline and the ten shared single-part benchmark prompts. The vendored packages/cadpy runtime also derives from this project and retains its original MIT copyright.
    • build123d — algebraic B-rep CAD kernel.
    • LangGraph — stateful agent orchestration.
    • Aider — LLM-driven code repair.
    • Qwen Model Studio — OpenAI-compatible models used in the documented experiments.