The script below will run fine when executed from within Blender 3 (text panel), but if I try to run it through the command line, it fails on line 25 with bad context (on rotation).
Any hint will be greatly appreciated!
Thx!
import os
import sys
import bpy
import glob
convert_dir = "c:/tmp/2convert"
for file in os.listdir(convert_dir):
if file.endswith(".svg"):
fullpath = convert_dir + "/" + file
for col in bpy.data.collections:
if ("svg" in col.name):
for oldobj in col.all_objects:
bpy.data.objects.remove(oldobj)
bpy.data.collections.remove(col)
fulloutputpath = os.path.splitext(fullpath)[0]+".svf"
bpy.ops.object.delete(use_global=False, confirm=False)
bpy.ops.import_curve.svg (filepath=fullpath)
for obj in bpy.data.collections[os.path.basename(fullpath)].all_objects:
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
bpy.ops.object.convert(target='MESH')
bpy.ops.transform.rotate(value=1.5708, orient_axis='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
if ("Bleedline" in obj.name):
bpy.ops.transform.translate(value=(0, 0.0005, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
obj.select_set(False)
bpy.ops.export_scene.fbx (filepath=fulloutputpath)
os.remove(fullpath)
```