- @scad.part/@scad.assemble anchor defaults to the builder script's own directory: cache + interface state land beside the source, standalone scripts run anywhere, and the pyproject.toml walk-up requirement is gone (explicit project_root still relocates the anchor) - file_input() paths resolve relative to the anchor; in-repo examples rewritten to script-relative declarations - HistCAD translator emits keyword-form sketch-family calls (corpus self-documentation), pinned by tests; booleans stay positional by *solids signature - both translators emit project_root=Path(__file__).parent explicitly; examples/histcad_demo regenerated (STEP volume reconciliation held) - FTC convention documents @scad.part parameters and the cache contract - version stamps 2.1.2 + bilingual update notes
2.4 KiB
2.1.2 更新说明
发布说明: 用于生产前,请验证生成的定义、装配约束和制造几何。
@part 缓存锚定到脚本目录(SDK 行为变更)
@scad.part / @scad.assemble 的锚点改为 builder 源文件所在目录,内容寻址
part 缓存与 interface 状态默认落在 <脚本目录>/.simplecad/:
- 独立脚本在任何位置都能运行——不再要求向上存在
pyproject.toml, 缺少工程根不会再在装饰阶段报错。 - 拷贝或删除脚本目录,缓存随之带走或清空。
file_input()路径相对锚点解析;脚本通常声明自己旁边的文件 (scad.file_input("model.py"))。- 需要工程级缓存时显式传
project_root=...——工程级缓存与[tool.simplecadapi.cache]配置表跟随显式锚点。环境变量覆盖 (SIMPLECAD_CACHE_DIR、SIMPLECAD_CACHE_MODE等)不变。
翻译语料 keyword 参数化
HistCAD→FTC 翻译器发射的全部草图族调用改为 keyword 形式
(scad.add_circle_rsketch(sketch=s, entity_id=..., center=..., radius=...)、
scad.constrain_distance_x_rsketch(sketch=s, a=..., b=..., value=...))。
翻译产物是训练语料:参数名让语义直接从源码可读。CadQuery 翻译器此前已有
同一钉子;现在两套测试套件都拒绝位置形式的草图族调用(布尔 *solids
变参按签名豁免)。
发射源显式声明缓存锚点
两个翻译器(histjson、cadqueryftc)都在 @scad.part 上显式发射
project_root=Path(__file__).parent——交付的 .ftc.py 自己声明缓存落点,
不依赖隐式解析。examples/histcad_demo 三个产物已重生成;STEP 体积对账
不变(1.63e-16 / 8.18e-05)。
FTC 规范:@part 参数与缓存契约
docs/skill/references/discipline/feature-tree-convention.md 新增一节,
写明装饰器的 keyword 参数(id、revision、inputs、cache、
project_root、tolerance_profile)、缓存与 interface 状态的落点、
覆盖链(装饰器 > 环境变量 > 工程配置 > 默认值)与缓存键构成。
兼容性说明
- 依赖旧的隐式工程根向上查找(共享
<repo>/.simplecad)的 builder, 现在默认得到脚本局部缓存;显式传project_root=...可保留旧锚定。 - 仓库内以工程根相对路径声明
file_input的示例,本版本已改写为 脚本相对路径。