Continue Blender Web parity task handoff
This commit is contained in:
46
tools/web/generated/M16-GAP-00201.py
Normal file
46
tools/web/generated/M16-GAP-00201.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def set_preview_range():
|
||||
window = bpy.context.window
|
||||
screen = window.screen
|
||||
area = next(candidate for candidate in screen.areas if candidate.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.previewrange_set.poll():
|
||||
raise RuntimeError("ANIM_OT_previewrange_set poll failed in animation editor context")
|
||||
result = bpy.ops.anim.previewrange_set(xmin=62, xmax=88, ymin=0, ymax=47)
|
||||
if "FINISHED" not in result:
|
||||
raise RuntimeError(f"ANIM_OT_previewrange_set 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-00201.py -- OUTPUT")
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
mesh = bpy.data.meshes.new("WebGapAnimPreviewRangeSetMesh")
|
||||
mesh.from_pydata(
|
||||
[(-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0)],
|
||||
[],
|
||||
[(0, 1, 2, 3)],
|
||||
)
|
||||
obj = bpy.data.objects.new("WebGapAnimPreviewRangeSetObject", mesh)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
bpy.context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
scene = bpy.context.scene
|
||||
scene.frame_start = 1
|
||||
scene.frame_end = 8
|
||||
set_preview_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