40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
OPERATIONS = ("Translate", "Merge", "Dissolve", "Extrude", "Inset", "Bevel", "LoopCut")
|
|
|
|
|
|
def square_mesh(name):
|
|
mesh = bpy.data.meshes.new(name)
|
|
mesh.from_pydata(
|
|
[(-1, -1, 0), (1, -1, 0), (1, 1, 0), (-1, 1, 0)],
|
|
[],
|
|
[(0, 1, 2, 3)],
|
|
)
|
|
mesh.update()
|
|
return mesh
|
|
|
|
|
|
def main(output):
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
collection = bpy.context.scene.collection
|
|
for label in OPERATIONS:
|
|
mesh = square_mesh("WBV2P2003%sMesh" % label)
|
|
obj = bpy.data.objects.new("WBV2P2003%sObject" % label, mesh)
|
|
collection.objects.link(obj)
|
|
active = bpy.data.objects["WBV2P2003TranslateObject"]
|
|
bpy.context.view_layer.objects.active = active
|
|
active.select_set(True)
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(output.resolve()), check_existing=False, compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --factory-startup --python WBV2-P2-003.py -- OUTPUT")
|
|
main(pathlib.Path(arguments[0]))
|