refactor: replace STL intermediary with OCC-native STEP→GLB pipeline
- export_step_to_gltf.py: STEP→GLB via RWGltf_CafWriter + BRepBuilderAPI_Transform (mm→m pre-scaling, XCAFDoc_ShapeTool.GetComponents_s static method) - Blender scripts (blender_render.py, still_render.py, turntable_render.py, export_gltf.py, export_blend.py): import GLB instead of STL, remove _scale_mm_to_m - step_tasks.py: add generate_gltf_production_task, remove generate_stl_cache, replace _bbox_from_stl with _bbox_from_glb (trimesh), auto-queue geometry GLB after thumbnail render - render_blender.py: replace _stl_from_cache_or_convert with _glb_from_step, remove convert_step_to_stl and export_per_part_stls - domains/rendering/tasks.py: update render_turntable_task, export_gltf/blend tasks to use GLB instead of STL - cad.py: remove STL download/generate endpoints, add generate-gltf-production - admin.py: generate-missing-stls → generate-missing-geometry-glbs - Frontend: replace STL cache UI with GLB generate buttons, remove stl_cached field Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
"""Blender headless script: export a STEP-derived scene as a production .blend.
|
||||
"""Blender headless script: export a geometry GLB as a production .blend.
|
||||
|
||||
Usage:
|
||||
blender --background --python export_blend.py -- \\
|
||||
--stl_path /path/to/file.stl \\
|
||||
--glb_path /path/to/geometry.glb \\
|
||||
--output_path /path/to/output.blend \\
|
||||
[--asset_library_blend /path/to/library.blend] \\
|
||||
[--material_map '{"SrcMat": "LibMat"}']
|
||||
|
||||
The script:
|
||||
1. Imports the STL file (with mm→m scale).
|
||||
1. Imports the geometry GLB (already in metres, Y-up).
|
||||
2. Optionally applies asset library materials from a .blend.
|
||||
3. Packs all external data.
|
||||
4. Saves a copy as the output .blend.
|
||||
@@ -28,7 +28,8 @@ def parse_args() -> argparse.Namespace:
|
||||
sys.exit(1)
|
||||
rest = argv[argv.index("--") + 1:]
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--stl_path", required=True)
|
||||
parser.add_argument("--glb_path", required=True,
|
||||
help="Geometry GLB from export_step_to_gltf.py (already in metres)")
|
||||
parser.add_argument("--output_path", required=True)
|
||||
parser.add_argument("--asset_library_blend", default=None)
|
||||
parser.add_argument("--material_map", default="{}")
|
||||
@@ -44,14 +45,8 @@ def main() -> None:
|
||||
# Clean scene
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
|
||||
# Import STL
|
||||
bpy.ops.import_mesh.stl(filepath=args.stl_path)
|
||||
|
||||
# Scale mm → m
|
||||
for obj in bpy.context.selected_objects:
|
||||
obj.scale = (0.001, 0.001, 0.001)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
bpy.ops.object.transform_apply(scale=True)
|
||||
# Import geometry GLB (metres, Y-up — no rescaling needed)
|
||||
bpy.ops.import_scene.gltf(filepath=args.glb_path)
|
||||
|
||||
# Apply asset library materials if provided
|
||||
if args.asset_library_blend and material_map:
|
||||
|
||||
Reference in New Issue
Block a user