* feat(skill): replace skill-pack with per-harness conditional compiler
skillbuild compiles the skill tree into per-target harness builds:
- <!-- skill:if omp,!claude --> blocks include text only for matching
targets; name-list conditions only, no else/nesting, fail-loud on
unknown targets and unpaired/nested directives
- fence-aware: directive-looking lines inside code fences are literal
- layout is the filesystem; tree root configured in skillproj.toml
- post-build assertion: zero directive residue, SKILL.md frontmatter
name check
Migration to the new model:
- docs/skill/ becomes the self-contained source root (SKILL.md,
references/, generated api/stdlib/core/guides now under
references/docs/; SDK_OVERVIEW/LICENSE/inspect are ordinary tree
files)
- auto_docs_gen output redirected into the tree (docs/api ->
docs/skill/references/docs/api, likewise stdlib)
- skills/simplecadapi/ is now the compiled omp target output;
dist/generic/simplecadapi the generic target
- dropped skill-pack entry point (plus dangling evolve/make-export
entries and their orphaned test), release workflow builds via
skillbuild + tar; README updated
First real conditional block: harness reading paths in SKILL.md
(skill:// mount on omp vs disk-relative on generic).
Verified: 59 tests pass (skillbuild 31, auto_docs_gen 19, persistence
regression 9); both targets build; outputs residue-clean; full suite
collects (1376 tests).
* refactor(tools): auto_docs_gen moves out of the installed package
tools/ scripts are repo-checkout dev scripts, not packaged CLIs:
- auto_docs_gen.py now lives in tools/ beside the other generators;
auto_tools/ package removed entirely
- path resolution simplifies: repo root = parent of tools/, fail-loud
if pyproject.toml missing; site-packages/cwd fallback branches were
dead code once the script stopped shipping in the wheel
- auto-docs-gen console script dropped from [project.scripts];
release.yml and README invoke python tools/auto_docs_gen.py
- MANIFEST.in stale src/auto_tools include removed; CadQuery-free
runtime scan no longer needs the auto_tools filter
- run_examples.py retired (user removal): README example-runner text
updated to direct examples/ scripts; dangling runner-contract test
(runpy.run_path into the deleted script) removed
Verified: 53 tests pass (auto_docs_gen + skill_build + ocp runtime
scan) and test_example_model_contract passes; regeneration from
tools/ is byte-identical (zero docs drift).
* refactor(skill): strip harness and build-tool content from the skill tree
The skill is plain harness-neutral content again:
- SKILL.md 'Reading skill files' section removed (the omp skill://
mount block and its !omp complement were the only conditional
blocks; the tree compiles identically for every target now)
- references/README.md: build-tool meta removed ('per-harness
conditional compilation', skillbuild packaging/validation claims —
link validation was never implemented, so the claim was false)
- live test now asserts the tree stays harness-neutral (zero blocks)
- skillproj.toml targets aligned with the user's output table
(omp -> skills/simplecadapi-omp, opencode -> skills/simplecadapi-opencode;
leftover 'generic' entry had no output and failed the build)
- compiled outputs are regenerable artifacts: skills/simplecadapi/
untracked from git, skills/simplecadapi-*/ gitignored, release.yml
and README build via skillbuild and tar the omp output directly
(bsdtar has no --transform; inner dir keeps its suffixed name)
Verified: 49 tests pass; both targets build 372 files with zero
conditional blocks; no omp/conditional/directive residue in the tree
or outputs.
* chore(docs): drop stale architecture review and design notes
4.9 KiB
SimpleCADAPI 2.0.2 更新说明
试验性版本提示: 以下能力均为试验性功能,后续版本可能引入 breaking changes(不兼容变更),因此不建议立即用于生产环境。
SimpleCADAPI 2.0.2 从 OCP 原生几何 API 进一步扩展为覆盖模型创建、参数与 公差分析、模型保存与回放、跨 CAD 转换、浏览器查看、装配验证和 STEP 逆向工程 的完整工作流。
1. FreeCAD、Fusion 360 和 SolidWorks 转换
规范化模型 JSON 可以转换为 FreeCAD、Fusion 360 和 SolidWorks 的自动化脚本。
安装 FreeCAD/FreeCADCmd 后,FreeCAD 后端还可以生成可编辑的 .FCStd 文档,
并在支持的范围内保留草图、特征、零件、装配体、链接和源选择信息。Fusion 360
后端面向其 Python 自动化环境生成脚本;SolidWorks 后端生成自动化脚本,并支持
通过 COM 驱动 STEP 导出。同一套参数化 SimpleCAD 模型可以作为多个 CAD 软件的
共同来源,无需维护互相分叉的脚本。
2. 浏览器三维场景查看器
viewer/ 应用可以直接打开生成的 .scene.zip 包,无需导入 Python 或
OpenCascade。查看器支持 GLB 几何和 CAD 边线渲染,提供旋转、平移、缩放等交互,
通过装配体/组件树查看模型结构,并控制单个实例的显示和隐藏。用户可以选择面、
边和顶点,查看面积、长度、体积或坐标等测量属性,以及语义标签和拓扑身份。
Features 视图会展示可回放的特征树、参数、输出数量、标签和内嵌源代码,并定位 到产生该特征的 Python 调用和高亮源代码行。场景包在加载资源前还会检查资源大小 和 SHA-256 完整性元数据。
3. 结构化保存、回放与源代码映射
通过 @model 或 GraphSession 记录的建模过程,可以导出规范化的模型/会话 JSON,
并使用 import_model_json(...) 和 replay_model_json(...) 确定性地重新生成模型。
场景导出可以把 scene.json、model/model.json、项目相对路径的 Python 源文件以及
GLB/entity 资源统一打包为一个可移植文件。
每个建模操作都会尽可能记录源代码溯源信息,因此特征树节点可以追溯到具体 Python 文件、函数调用、赋值目标和行号范围。这为自动化、协作、回归测试和版本化模型审查 提供了基础。
4. 物理单位和尺寸公差分析
带单位的变量会在模型图中保留声明单位,同时将 CAD 操作统一转换为毫米和角度。 表达式会在算术运算和受支持的三角函数中自动推导物理维度,拒绝不兼容的维度混用, 并把参数关系保留到可回放的模型数据中。
制造公差可以沿尺寸链传播,生成名义值和上下界,并与显式的公差要求进行检查, 用于单位换算、尺寸链分析和装配公差研究。
5. 机械标准件库与齿轮性能
标准件库新增或完善了参数化螺栓、螺母、滚珠轴承、滚子链链轮,以及直齿、斜齿、 人字齿、内齿圈、齿条、摆线盘和直齿锥齿轮等常用机械零件。这些工厂函数返回普通 SimpleCAD 形状或装配体,可以像自定义几何一样继续进行变换、打标签、布尔组合、 序列化、跨软件转换和导出。
齿轮构造和标准件库的图追踪也进行了优化;在代表性齿轮工作负载下,建模时间约 缩短到原来的三分之一。
6. 装配体、网格和碰撞检查
零件、组件、连接器、放置关系和装配体可以保存为结构化产品树,并支持固定、旋转、 移动、齿轮、皮带以及齿轮齿条等约束。约束求解和残差检查让装配关系变得可计算、 可度量。系统可以生成用于场景资源和后续检查的三角网格与边线网格。
安装可选依赖 simplecadapi[collision] 后,可以通过 python-fcl 对当前姿态执行
静态网格穿透检查,配置组件范围和允许穿透量,并输出接触点、法向和穿透深度。当前
版本的检查器针对网格接触穿透,不负责运动求解,也不能覆盖所有完全包含的实体重叠情况。
7. STEP 检查和逆向工程诊断
simplecad-brep 命令行工具以及 simplecadapi.inverse_engineer.brep API 可以读取
STEP BREP,报告体积、表面积、包围盒、拓扑数量和几何基元类型。双向比较可以将几何
点集一致性和带几何标签的面-边-顶点关联图作为严格门槛,避免仅凭体积差判断模型一致性。
工具还支持生成统一视角的 STEP 渲染图,并对指定物理截面进行采样和 XOR 叠加比较, 用于验证重建零件在几何形状和拓扑结构上是否与原始零件一致。