openscad

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

OpenSCAD Design Skill

OpenSCAD 设计技能

Create versioned OpenSCAD files, render previews, and compare iterations for 3D printing designs.
为3D打印设计创建带版本号的OpenSCAD文件、渲染预览图并对比迭代版本。

Workflow

工作流

1. Determine the Next Version Number

1. 确定下一个版本号

Before creating a new .scad file, find existing versions:
bash
.claude/skills/openscad/scripts/version-scad.sh <name>
This returns the next version number and filename. For example, if
piano_001.scad
exists, it returns
piano_002
.
在创建新的.scad文件前,先查找已有的版本:
bash
.claude/skills/openscad/scripts/version-scad.sh <name>
该命令会返回下一个版本号和文件名。比如,如果已经存在
piano_001.scad
,就会返回
piano_002

2. Create the Versioned .scad File

2. 创建带版本号的.scad文件

Write the OpenSCAD code to the versioned filename (e.g.,
piano_002.scad
).
将OpenSCAD代码写入对应版本号的文件中(例如
piano_002.scad
)。

3. Render the Preview

3. 渲染预览图

bash
.claude/skills/preview-scad/scripts/render-scad.sh <name>_<version>.scad --output <name>_<version>.png
This creates a PNG with the matching version number (e.g.,
piano_002.png
).
bash
.claude/skills/preview-scad/scripts/render-scad.sh <name>_<version>.scad --output <name>_<version>.png
这会生成对应版本号的PNG图片(例如
piano_002.png
)。

4. Compare with Previous Version

4. 和上一个版本对比

Read both the current and previous PNG images to visually compare:
  • Current:
    piano_002.png
  • Previous:
    piano_001.png
    (if exists)
Evaluate what changed and whether the new version better matches requirements.
读取当前版本和上一版本的PNG图片进行视觉对比:
  • 当前版本:
    piano_002.png
  • 上一版本:
    piano_001.png
    (如果存在的话)
评估改动内容,以及新版本是否更符合需求。

5. Iterate

5. 迭代

If the design needs improvement:
  1. Analyze what's wrong
  2. Create the next version (e.g.,
    piano_003.scad
    )
  3. Render and compare again
如果设计需要优化:
  1. 分析存在的问题
  2. 创建下一个版本(例如
    piano_003.scad
  3. 再次渲染并对比

File Naming Convention

文件命名规范

<model-name>_<version>.scad  ->  <model-name>_<version>.png
Examples:
  • phone_stand_001.scad
    ->
    phone_stand_001.png
  • phone_stand_002.scad
    ->
    phone_stand_002.png
  • gear_001.scad
    ->
    gear_001.png
Use underscores in model names, and always use 3-digit zero-padded version numbers.
<model-name>_<version>.scad  ->  <model-name>_<version>.png
示例:
  • phone_stand_001.scad
    ->
    phone_stand_001.png
  • phone_stand_002.scad
    ->
    phone_stand_002.png
  • gear_001.scad
    ->
    gear_001.png
模型名称中使用下划线,版本号统一使用3位补零的格式。

Example Session

示例使用流程

User asks for a piano model:
  1. Check for existing versions:
    bash
    .claude/skills/openscad/scripts/version-scad.sh piano
    Output:
    piano_001
    (no existing files)
  2. Write
    piano_001.scad
    with initial design
  3. Render preview:
    bash
    .claude/skills/preview-scad/scripts/render-scad.sh piano_001.scad --output piano_001.png
  4. Read
    piano_001.png
    to inspect the result
  5. If improvements needed, create
    piano_002.scad
    , render to
    piano_002.png
  6. Read both
    piano_001.png
    and
    piano_002.png
    to compare iterations
用户需要一个钢琴模型:
  1. 检查已有的版本:
    bash
    .claude/skills/openscad/scripts/version-scad.sh piano
    输出:
    piano_001
    (没有已存在的文件)
  2. 编写初始设计代码存入
    piano_001.scad
  3. 渲染预览图:
    bash
    .claude/skills/preview-scad/scripts/render-scad.sh piano_001.scad --output piano_001.png
  4. 读取
    piano_001.png
    检查设计结果
  5. 如果需要优化,创建
    piano_002.scad
    ,渲染生成
    piano_002.png
  6. 同时读取
    piano_001.png
    piano_002.png
    对比迭代差异

Render Options

渲染选项

See
/preview-scad
for full rendering options:
  • --size <WxH>
    - Image dimensions (default:
    800x600
    )
  • --camera <x,y,z,tx,ty,tz,d>
    - Camera position
  • --colorscheme <name>
    - Color scheme (default:
    Cornfield
    )
  • --render
    - Full render mode (slower, more accurate)
  • --preview
    - Preview mode (faster, default)
完整的渲染选项可查看
/preview-scad
  • --size <WxH>
    - 图片尺寸(默认:
    800x600
  • --camera <x,y,z,tx,ty,tz,d>
    - 相机位置
  • --colorscheme <name>
    - 配色方案(默认:
    Cornfield
  • --render
    - 完整渲染模式(速度较慢,精度更高)
  • --preview
    - 预览模式(速度更快,默认选项)

Next Steps

后续步骤

Once the design looks correct in PNG previews:
  1. Export to STL: Use
    /export-stl
    to convert the final version to STL format
  2. The export includes geometry validation to catch printability issues
当设计在PNG预览中看起来无误后:
  1. 导出为STL:使用
    /export-stl
    将最终版本转换为STL格式
  2. 导出过程会包含几何验证,以排查可打印性问题

Full Pipeline

完整流程

/openscad → /preview-scad → /export-stl (with validation)
/openscad → /preview-scad → /export-stl (with validation)

Tips

提示

  • Start simple and add complexity in iterations
  • Use meaningful model names that describe the object
  • Keep each version's changes focused on specific improvements
  • Document what changed between versions in your response to the user
  • Only export to STL once the preview looks correct
  • Always run slice-check before considering a model print-ready
  • 从简单版本开始,迭代中逐步增加复杂度
  • 使用能描述物体的、有意义的模型名称
  • 每个版本的改动要聚焦于特定的优化点
  • 在给用户的回复中记录版本之间的改动内容
  • 仅在预览无误后再导出为STL
  • 在判定模型可打印前务必运行切片检查