科研 Skill
产品外壳参数化建模
enclosure-engineer
Designs a hardware enclosure as parametric CAD with STEP/STL/GLB output, a DFM check, and Blender assembly validation. Use when designing a case or checking fit.
SKILL.md
Enclosure engineer
You turn the electronics and the industrial-design intent into an enclosure that a molder can quote and an assembly that can be built and sealed. The output is ready to build: STEP files per part, a DFM report, and a validated assembly.
Two tools, two jobs:
- CAD (build123d) is the source of truth for enclosure geometry. A JSON spec produces exact B-rep parts. It exports STEP for molders and print services, STL for prototypes and GLB for Blender, and runs a DFM check.
- Blender is the assembly, validation and render stage. It imports the GLB, places the PCB and battery, fits movable parts and validates. It never edits the enclosure. A geometry change goes back to the spec.
Talk to the user in their language. Show progress as images (viewport captures or quick renders), and save each one.
Prerequisites
Run commands from inside this skill's own directory (the folder containing this SKILL.md), since script and reference paths below (such as scripts/foo.py) are written relative to it, not to the project root.
Inputs
hw/brief.md: size limits, how the product is worn or used, colors and finishes, environment (sweat, rain, drops).hw/requirements.md: dimensional, ingress (IP) and drop requirements.hw/architecture.mdandhw/bom.csv: which parts exist, theirsize_max_mm, connectors, battery, antenna keep-outs.hw/pcb/: board outlines and 3D exports (GLB/VRML/STEP frompcb-engineer).hw/power/: battery dimensions and swelling allowance frombattery-and-power.
Outputs
hw/mech/enclosure.json: the enclosure spec (fromtemplates/enclosure.example.json).hw/mech/cad/:<name>_<part>.step,<name>_assembly.step,<name>_<part>.stl,<name>_assembly.glb, keep-out STEP/GLB,<name>_dfm.jsonand<name>_dfm.md.hw/mech/build_assembly.py: the scripted Blender assembly (imports the CAD GLB and the PCB export), run withblender -b --python.hw/mech/assembly_golden.blend: the frozen, validated assembly. Every render and drawing starts from this file.hw/mech/stackup.md: the Z stack, layer by layer, with nominal, minimum and maximum values. It lists every gap under 0.3 mm.hw/mech/tolerances.md: the tolerance stack-up of each critical gap, worst case and RSS.hw/mech/dfm.md: the molding review (walls, draft, gates, undercuts, side actions, finish) and the questions for the molder.hw/validation/assembly.jsonandassembly.txt: the validator report of the golden file.- Entries in
hw/decisions.mdfor every mechanical trade-off: wall thickness against battery volume, sealing method, and similar choices.
Gate
The next stage (renders, drawings, cost quotes) starts only when:
cad_enclosure.pyreports DFM PASS. Every undercut and undrafted warning is either removed or accepted inhw/mech/dfm.md, with the mechanism and cost it needs.validate_assembly.pypasses on the golden file: 0 interpenetrations deeper than 0.02 mm, and no non-manifold or non-finite mesh.free_space.pyreports no leak for every cavity that must be sealed.- Every gap under 0.3 mm has a tolerance stack-up with a positive worst-case or a stated RSS risk.
- The DFM review has no open "cannot mold" item, and the STEP files open in a second tool (any CAD viewer) with the right size.
Tools (scripts/)
| Script | What it does |
|---|---|
scripts/cad_enclosure.py | JSON spec → B-rep shell, lid (adhesive lip, snap, captive screws + flat gasket, or twist), optional round battery door (screws or twist), joint parts and features → STEP, STL, GLB + DFM check (walls, draft, undercuts, keep-outs). Runs with cad_python from toolchain.json (build123d venv, Python 3.10–3.13). scripts/test_cad_joints.py is its regression test. |
scripts/import_cad_glb.py | Imports the CAD GLB (and keep-outs) into a millimetre Blender scene as tagged components, validates and saves. |
scripts/validate_assembly.py | Interpenetration and mesh-quality gate. Writes JSON + text, exits 1 on failure. |
scripts/free_space.py | Voxel flood fill of the cavity: leak detection, distance field, rigid fit of movable parts. |
scripts/enclosure_example.py | A Blender-only demo of fitting and validation: shell, lid, PCB, components, battery. Use it to learn the gate, not to design. |
# CAD: build, export, DFM check, in the build123d venv that toolchain-setup records as `cad_python`
CAD_PY=$(python3 -c "import json,os; p=[x for x in ('hw/toolchain.json', os.path.expanduser('~/.config/hardware-design-toolkit/toolchain.json')) if os.path.isfile(x)][0]; print(json.load(open(p))['paths']['cad_python'])")
"$CAD_PY" scripts/cad_enclosure.py hw/mech/enclosure.json --out hw/mech/cad
# into Blender with keep-outs, validated
blender -b --factory-startup --python scripts/import_cad_glb.py -- --glb hw/mech/cad/<name>_assembly.glb \
--keepouts hw/mech/cad/<name>_keepouts.glb --validate hw/validation/enclosure --save hw/mech/assembly.blend
# the example, start to finish (seconds)
blender -b --factory-startup --python scripts/enclosure_example.py -- --out /tmp/hdt_example --collide
# gate an assembly (validate in the unposed frame of the root)
blender -b hw/mech/assembly_golden.blend --python scripts/validate_assembly.py -- \
--root Assembly --json hw/validation/assembly.json --txt hw/validation/assembly.txt
# fit a movable part (battery) against fixed collections, along z only
blender -b hw/mech/assembly.blend --python scripts/free_space.py -- \
--fixed-collection Shell --fixed-collection Boards --movable "Battery cell" \
--clearance 0.10 --lock 0 0 1 --save hw/mech/assembly_fitted.blend
free_space.py uses cupy (GPU) or scipy when they are present, and falls back to numpy only. Blender does not bundle scipy. To install it into Blender's Python, use toolchain-setup. For a one-off run, use PYTHONPATH=<dir with scipy> blender --python-use-system-env .... Grids above about 60 M voxels belong on a GPU machine, not on the laptop that is running the session.
Workflow
1. Envelope and stack-up first
Before any modelling, write hw/mech/stackup.md. List the Z stack from the outer skin to the back cover: wall, gap, flex or board, tallest component, gap, battery and its swelling allowance, gap, back wall. Use the maximum dimensions from the datasheets. Nominal heights hide the gaps that later fail. If the stack does not fit the brief's thickness, say so now and offer options: a smaller cell, fewer layers, components on the other side, or a thicker product. Do not shrink a part below what exists.
2. Enclosure in CAD
Read references/cad-pipeline.md. Copy templates/enclosure.example.json to hw/mech/enclosure.json and fill it from the brief and the stack-up:
- outline, height and wall;
- fillets and draft;
- the lid joint;
- windows, ports and tunnels;
- bosses and ribs;
- keep-outs for the board, the components and the cell, at their maximum size.
Run cad_enclosure.py and fix every DFM error in the spec. Review every warning with the user when it costs money, for example a side action for a cord tunnel.
3. Assemble in Blender, in a fixed build order
Read references/assembly-pipeline.md before you write build_assembly.py. It starts from import_cad_glb.py (the enclosure) and adds the PCB export and the battery. Rules:
- Set scene units to millimetres (
unit_settings.scale_length = 0.001, length unitMILLIMETERS). One Blender unit is 1 mm. - One root EMPTY named
Assembly. Each physical component is an EMPTY with the custom propertyhdt_component = True(the validator still reads the legacy namevh_component), and its meshes are children. The validator never tests meshes of the same component against each other. - Never model or cut the enclosure in Blender. Booleans in Blender are only for non-deliverable helpers. If you use them, apply them with the EXACT solver (evaluate, then
bpy.data.meshes.new_from_object), and make shared mesh data single-user before you cut it. - Imported vendor models (KiCad GLB, STEP converted to mesh) keep their own empties. Treat containers like
Node,Rootand=>…as containers (--container-regex). - Build order: fixed structure → boards → mated connectors (fixed constraints) → springs and contacts (fit to their working height) → membranes and gaskets → free-space fit of movable bodies → battery last among bodies → small details (solder, markings, owned by
product-render) → validate → freeze. - Save the result as
assembly_golden.blend. Appearance-only work (materials, lights, cameras) loads the golden file and never moves geometry.
4. Fit, do not nudge
When a part collides, do not move it by hand until the render looks right. Run free_space.py: it measures the free space around the part and moves it the minimum distance along the escape direction. If the fit needs more than the design allows (for example the battery has to rise 0.4 mm but the stack has 0.1 mm), that is a design finding. Report it, and change the source: placement, pocket, part height or cell size.
5. Validate, then freeze
Run the validator on the whole assembly in its unposed frame. A posed or rotated copy for a photo is validated before it is posed. Rotation changes floating-point precision on coplanar contacts.
- Every failure is fixed at its source. There is no whitelist. A simplified vendor model that collides is replaced by the vendor's real 3D model.
- If two fixes keep undoing each other, stop. Change the build order so that each step depends only on the steps before it, then rebuild from the start.
6. Tolerances and DFM
- Read
references/tolerances.mdand do the stack-up for every gap under 0.3 mm and every spring or contact working height. - Read
references/dfm-injection-molding.mdand review every molded part beyond what the automated check sees: gate position and weld lines, finish, shrink, and the questions for the molder. - Read
references/sealing-and-ingress.mdfor every opening: microphone and speaker ports, buttons, charging contacts, seams, cord or strap holes. - Read
references/materials.mdbefore you pick a resin, metal or finish.
Taste and pitfalls
- Fewer holes. Each opening costs sealing, tooling and certification effort. Prefer molded-in contacts, adhesive-sealed seams, capacitive touch through the wall, and membranes over open grilles.
- Real batteries have straight edges. A pouch cell is a rectangle (or a simple polygon) with a sealed border of about 1 mm and tabs. It is not a blob shaped to fill the leftover space. Keep a swelling allowance above it: about 8–10% of cell thickness over its life [estimate: typical pouch swelling guidance; confirm with the cell vendor].
- Use maximum dimensions. LED, crystal and connector heights in distributor listings are often larger than the "typical" figure in the datasheet. When the two disagree, model the larger one.
- A clean mesh is not a real mesh. Mold parting lines, draft, ejector-pin marks and gate vestiges exist. Include the ones that show in renders, or at least keep draft on vertical walls so that reflections behave.
- Clear parts are special. Weld lines, gate blush, sink and every internal feature show through. Gate into a hidden area, keep walls uniform, and polish to SPI A1/A2.
- An arched tunnel needs a curved core (an expensive tool). The cheaper option is to split the tunnel at the parting line, so that each half is a straight pull.
- Contact is allowed and penetration is not. Parts that seat face to face pass the validator, so model them that way. Do not leave a fake 0.001 mm gap.
- One source of truth. Enclosure changes go into the spec and the CAD rebuild. A shell edited by hand in Blender no longer matches the STEP file the molder quotes.
- Undercuts cost money. Each cluster the DFM check reports means a slide or a lifter in the tool. Remove it, or show the user its cost and get a decision.
- A twist lid needs a round product; a round door does not. A bayonet that turns the whole lid only works on a circular outline, and on a thin product its lugs need the space the battery holder takes. For a coin cell in any outline, put a round door in the lid. Captive screws (
lid.door.retention: screws) are tool-secured for coin-cell child-safety rules and mold in a straight pull. Bayonet lugs need side actions. - Stop when it regresses. Repeated "fix one thing, break another" cycles mean the build order is wrong. Redesign the order and rebuild. Do not keep patching.
References
| File | Read when |
|---|---|
references/cad-pipeline.md | writing the enclosure spec; reading the DFM report; sending files to a molder |
references/assembly-pipeline.md | before writing or changing build_assembly.py; when fixes regress |
references/free-space-and-flex.md | fitting parts, flex circuits that drape over components, leak findings |
references/tolerances.md | any gap < 0.3 mm, springs, press fits, snap fits, battery pockets |
references/dfm-injection-molding.md | every molded part; before an RFQ to a molder |
references/sealing-and-ingress.md | any opening, seam, port or IP requirement |
references/materials.md | choosing resins, metals, inserts, finishes, skin-contact materials |
示例提示词
帮我用参数化CAD设计这个产品的外壳并做可制造性检查。
所属插件
安装该插件会一并获得同领域的 63 个 Skill / MCP。
同插件的其他科研 Skill
- ANDES电力系统动态仿真Runs ANDES power-system dynamic studies via PowerMCP: power flow, eigenvalue analysis, and time-domain simulation. Use for damping, stability, or oscillation-mode questions.
- 电池选型与电源预算Builds an evidence-tagged power budget and sizes a manufacturable battery with pouch outline, seals, and derating. Use when sizing runtime, mAh, charging, or supply rails.
- FPGA比特流生成与烧录Generates a Xilinx FPGA bitstream and programs it over JTAG, or burns an MCS image into flash for power-on boot. Use when flashing a board or diagnosing boot failures.
- 硬件项目发布包组装Assembles a hardware release package (fab files, BOM/CPL, carts, assembly guide, hashed manifest) and runs a ready-to-build gate. Use before ordering prototypes.
- 时钟域交叉风险审查Audits clock-domain-crossing risk on an FPGA design and applies the smallest safe synchronizer or constraint fix. Use to resolve CDC violations before sign-off.
- 硬件产品认证合规规划Plans certifications a hardware product needs per target market (FCC, CE/RED, UKCA, battery/radio rules), with cost and lead-time estimates. Use before PCB or enclosure tooling.
- Vivado XDC时序约束编写Authors a Vivado XDC timing constraint set from scratch: clocks, I/O delays, and timing exceptions. Use first, before timing closure, on a design with no or incomplete constraints.
- N-1/N-2应急违规处置Playbook for N-1/N-2 contingency violations: ranks contingencies and proposes preventive and corrective actions. Use after a study shows voltage or thermal problems.
- 潮流计算不收敛诊断Playbook for power-flow convergence failures in PSS/E, PSLF, PowerWorld, pandapower, PyPSA, surge, or OpenDSS. Use when a case diverges or fails to solve.
- 硬件成本核算与采购Prices a hardware product at multiple volumes with one-time vs per-unit cost, landed cost per country, and sourcing leads. Use to estimate unit cost before a pitch.
- RTL仿真覆盖率收敛Measures RTL simulation code coverage and iteratively closes it toward a target by adding testbench stimulus. Use for a sign-off-grade coverage report.
- 配电网DER接纳能力治理Playbook for distribution DER hosting-capacity limits: voltage rise, reverse flow, and thermal limits from PV and storage. Use to estimate how much DER a feeder can host.
- 电子电路设计与审查Designs, audits, or corrects an electronic circuit from a brief, schematic, or netlist, checking power domains, reset sequencing, and ratings. Use for circuit review.
- 硬件可制造性红队审查Red-team audit that fix-loops a hardware project to ready-to-build, re-deriving parts, rails, battery physics, and cost. Use for a reality check before committing to a design.
- 电力系统动态稳定处置Playbook for dynamic stability problems: poor damping, angle instability, or sustained oscillations from eigenvalue or time-domain studies. Use after an unstable study result.
- Egret电力市场调度优化Runs Egret market/operations optimization (DC-OPF, AC-OPF, unit commitment) via PowerMCP. Use for cheapest dispatch, unit commitment, or congestion checks.
- 电子元器件选型核查Researches electronic components against primary sources: part numbers, datasheet limits, lifecycle, stock, and price breaks, one dossier per part. Use to verify or source a BOM.
- EMC电磁兼容预测试Plans grounding, shielding, and filtering for EMC/EMI, and runs an emissions pre-scan with a root-cause fix sequence. Use before a lab test or after a failed EMI scan.
- 电网频率响应问题处置Playbook for frequency problems: low inertia, high RoCoF, weak primary response, or UFLS risk after loss of the largest unit. Use when a study flags frequency issues.
- FPGA RTL到比特流全流程Drives a Xilinx FPGA design end to end through RTL, simulation, synthesis, implementation, and bitstream, gated at every stage. Use to run the complete build flow in one pass.
- 硬件产品全流程总协调Leads a physical electronic product from idea to a doable design, coordinating specs, parts, battery, PCB, enclosure, render, and cost sub-skills. Use starting a hardware product.
- 硬件原理图与BOM审查Reviews hardware projects: checks schematics against datasheets, pin connections, and firmware-to-hardware alignment across KiCad/Altium files. Use for a design alignment check.
- FPGA ILA在线逻辑调试Inserts an Integrated Logic Analyzer, programs the board, arms a trigger, and reads captured waveforms on real FPGA hardware. Use when sim passes but the board fails.
- 新能源并网影响评估Playbook for screening the grid impact of a new generator, storage, or large-load interconnection. Use to check whether a given MW can connect and what upgrades it needs.
常见问题
产品外壳参数化建模能做什么?
Designs a hardware enclosure as parametric CAD with STEP/STL/GLB output, a DFM check, and Blender assembly validation. Use when designing a case or checking fit。
如何安装产品外壳参数化建模?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「产品外壳参数化建模」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
产品外壳参数化建模需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
产品外壳参数化建模经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。