Continue Blender Web parity task handoff
This commit is contained in:
43
tools/web/generated/M16-GAP-00204.py
Normal file
43
tools/web/generated/M16-GAP-00204.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def frame_scene_range():
|
||||
window = bpy.context.window
|
||||
screen = window.screen
|
||||
area = next((candidate for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR" and candidate.height >= 200), None)
|
||||
if area is None:
|
||||
area = next(candidate for candidate in screen.areas if candidate.type == "VIEW_3D" and candidate.height >= 200)
|
||||
area.type = "DOPESHEET_EDITOR"
|
||||
region = next(candidate for candidate in area.regions if candidate.type == "WINDOW")
|
||||
with bpy.context.temp_override(window=window, screen=screen, area=area, region=region):
|
||||
if not bpy.ops.anim.scene_range_frame.poll():
|
||||
raise RuntimeError("ANIM_OT_scene_range_frame poll failed in animation editor context")
|
||||
result = bpy.ops.anim.scene_range_frame()
|
||||
if "FINISHED" not in result:
|
||||
raise RuntimeError(f"ANIM_OT_scene_range_frame returned {result}")
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 1:
|
||||
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00204.py -- OUTPUT")
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
scene = bpy.context.scene
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = 48
|
||||
scene.use_preview_range = True
|
||||
scene.frame_preview_start = 12
|
||||
scene.frame_preview_end = 24
|
||||
bpy.context.preferences.view.smooth_view = 0
|
||||
frame_scene_range()
|
||||
bpy.ops.wm.save_as_mainfile(
|
||||
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user