添加cadfs_to_cdsl代码,优化cad生成

This commit is contained in:
2026-09-03 10:40:51 +08:00
parent f3eb5dff54
commit c25b73c71e
34 changed files with 3586 additions and 147 deletions
@@ -129,6 +129,8 @@ def download_one(ref: PartStudioRef, authorization: str, raw_root: Path, *, time
("tessellated_edges", part_studio_path(ref, "/tessellatededges"), "tessellated_edges.json", common),
("shaded_views", part_studio_path(ref, "/shadedviews"), "shaded_views.json", {"viewMatrix": "front", "outputWidth": 512, "outputHeight": 512, "edges": "show", "showAllParts": "true"}),
]
if os.environ.get("ONSHAPE_FAST_STEP") == "1":
resources = [item for item in resources if item[0] not in {"tessellated_faces", "tessellated_edges", "shaded_views"}]
# These document and Part Studio evidence endpoints are independent. A
# bounded fan-out keeps an interactive acquisition from being cut off
# before it can reach the asynchronous STEP export, while preserving the
@@ -136,12 +138,13 @@ def download_one(ref: PartStudioRef, authorization: str, raw_root: Path, *, time
worker_count = max(1, min(16, int(os.environ.get("ONSHAPE_DOWNLOAD_WORKERS", "4"))))
with ThreadPoolExecutor(max_workers=worker_count, thread_name_prefix="onshape-download") as executor:
artifacts.extend(executor.map(lambda item: _save(client, root, *item), resources))
artifacts.extend(_sketch_artifacts(client, root))
artifacts.extend([
_save(client, root, "parasolid", part_studio_path(ref, "/parasolid"), "model.x_t", {"version": "0", "includeExportIds": "true", "binaryExport": "false"}, "text/plain, application/octet-stream"),
_save(client, root, "gltf", part_studio_path(ref, "/gltf"), "model.gltf", {**common, "outputSeparateFaceNodes": "true"}, "model/gltf+json, application/octet-stream"),
_export_step(client, root, ref.sample_id, poll_seconds, poll_limit),
])
if os.environ.get("ONSHAPE_FAST_STEP") != "1":
artifacts.extend(_sketch_artifacts(client, root))
manifest = {"schema": "onshape_to_cdsl.raw_sample.v1", "source": ref.as_dict(), "resource_count": len(artifacts), "downloaded_count": sum(item.status in {"downloaded", "reused"} for item in artifacts), "unavailable_count": sum(item.status not in {"downloaded", "reused"} for item in artifacts), "resources": [asdict(item) for item in artifacts]}
write_json(root / "manifest.json", manifest)
return manifest