41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
|
|
# Stage 41: open the finished body in the Blender GUI, framed and shaded, ready to orbit.
|
||
|
|
#
|
||
|
|
# blender <blend> --python 41_show.py
|
||
|
|
#
|
||
|
|
# Runs inside the GUI session (not --background): sets every 3D viewport to Material Preview so
|
||
|
|
# her maps are visible, frames her, and turns off the overlays that clutter a review.
|
||
|
|
import bpy
|
||
|
|
|
||
|
|
|
||
|
|
def setup():
|
||
|
|
ob = max([o for o in bpy.data.objects if o.type == 'MESH'],
|
||
|
|
key=lambda o: len(o.data.vertices))
|
||
|
|
bpy.context.view_layer.objects.active = ob
|
||
|
|
for o in bpy.data.objects:
|
||
|
|
o.select_set(o is ob)
|
||
|
|
|
||
|
|
for area in bpy.context.screen.areas:
|
||
|
|
if area.type != 'VIEW_3D':
|
||
|
|
continue
|
||
|
|
space = area.spaces.active
|
||
|
|
space.shading.type = 'MATERIAL'
|
||
|
|
space.shading.use_scene_lights = False
|
||
|
|
space.shading.use_scene_world = False
|
||
|
|
space.overlay.show_floor = False
|
||
|
|
space.overlay.show_axis_x = False
|
||
|
|
space.overlay.show_axis_y = False
|
||
|
|
space.overlay.show_relationship_lines = False
|
||
|
|
space.clip_start = 0.01
|
||
|
|
space.clip_end = 100.0
|
||
|
|
for region in area.regions:
|
||
|
|
if region.type == 'WINDOW':
|
||
|
|
with bpy.context.temp_override(area=area, region=region):
|
||
|
|
bpy.ops.view3d.view_axis(type='FRONT')
|
||
|
|
bpy.ops.view3d.view_selected()
|
||
|
|
print("SHOW_READY", flush=True)
|
||
|
|
return None
|
||
|
|
|
||
|
|
|
||
|
|
# the screen is not ready during --python execution at load time; defer one tick
|
||
|
|
bpy.app.timers.register(setup, first_interval=0.5)
|