a18d4c23ec
- feat(migration): 045_asset_libraries — new asset_libraries table (blend_file_path, catalog JSONB) - feat(model): AssetLibrary SQLAlchemy model in domains/materials/models.py - feat(api): POST/GET/PATCH/DELETE /api/asset-libraries + /upload-blend + /refresh-catalog endpoints - feat(celery): refresh_asset_library_catalog task on thumbnail_rendering queue — runs Blender headless - feat(blender): catalog_assets.py — extracts asset-marked materials + node_groups from .blend - feat(blender): asset_library.py — apply_asset_library_materials + apply_asset_library_node_groups helpers - feat(blender): export_gltf.py — STEP→STL→GLB production export with optional asset library - feat(blender): export_blend.py — STEP→STL→.blend production export with pack_all() - feat(frontend): api/assetLibraries.ts — full CRUD API client - feat(frontend): AssetLibraryPanel in Admin.tsx — upload, refresh, expand catalog view - docs: Blender asset_data marking requirement learning in LEARNINGS.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
"""Blender headless script: extract asset catalog from a .blend library file.
|
|
|
|
Usage:
|
|
blender --background --python catalog_assets.py -- <blend_path>
|
|
|
|
Outputs a single JSON line to stdout:
|
|
{"materials": ["Mat1", "Mat2", ...], "node_groups": ["NG1", ...]}
|
|
|
|
Only assets marked via Blender's asset system (asset_data is not None) are included.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
import traceback
|
|
|
|
|
|
def main() -> None:
|
|
argv = sys.argv
|
|
if "--" not in argv:
|
|
print(json.dumps({"error": "No blend path provided after --"}))
|
|
sys.exit(1)
|
|
|
|
blend_path = argv[argv.index("--") + 1]
|
|
|
|
import bpy # type: ignore[import]
|
|
|
|
bpy.ops.wm.open_mainfile(filepath=blend_path)
|
|
|
|
materials = [m.name for m in bpy.data.materials if m.asset_data is not None]
|
|
node_groups = [ng.name for ng in bpy.data.node_groups if ng.asset_data is not None]
|
|
|
|
catalog = {"materials": materials, "node_groups": node_groups}
|
|
print(json.dumps(catalog))
|
|
|
|
|
|
try:
|
|
main()
|
|
except SystemExit:
|
|
raise
|
|
except Exception:
|
|
traceback.print_exc()
|
|
sys.exit(1)
|