Files
sunrise/scripts/export-photo-rocks.py

21 lines
1.3 KiB
Python

"""Re-export edited photo-guided-rocks.blend via Blender MCP, without regenerating it."""
import bpy
import io_scene_gltf2
from pathlib import Path
root=Path('D:/project/sunrise')
scene=bpy.data.scenes['Photo-guided summit rocks']
bpy.context.window.scene=scene
rocks=bpy.data.collections['Photo rocks - export']
for obj in scene.objects:obj.select_set(False)
for obj in rocks.objects:obj.select_set(True)
bpy.context.view_layer.objects.active=next(iter(rocks.objects))
fmt=next(item[0] for item in io_scene_gltf2.get_format_items(None,bpy.context) if item[0]=='GLB')
rna=bpy.ops.export_scene.gltf.get_rna_type().properties
materials=next(item.identifier for item in rna['export_materials'].enum_items if item.identifier=='NONE')
colors=next(item.identifier for item in rna['export_vertex_color'].enum_items if item.identifier=='ACTIVE')
bpy.ops.export_scene.gltf(filepath=str(root/'public/models/summit/radar-rocks.glb'),export_format=fmt,
use_selection=True,use_active_scene=True,export_yup=True,export_apply=True,
export_materials=materials,export_vertex_color=colors,export_active_vertex_color_when_no_material=True,
export_animations=False,export_cameras=False,export_lights=False,export_extras=True)
bpy.ops.wm.save_as_mainfile(filepath=str(root/'assets/summit/blender-rock-study/photo-guided-rocks.blend'))