2
$\begingroup$

I have noticed that if blender is launched in background with a python script and arguments via a subprocess, it seems not to work...

For example, with a script to rename a material in a blend file called ren.py :

import os
import sys
import subprocess
#sub = subprocess.Popen(['blender', '/home/pegasi/green.blend', '--python', '/home/pegasi/change_material_name.py', 'green', 'plip'])
sub = subprocess.Popen(['blender', '--background', '/home/pegasi/green.blend', '--python', '/home/pegasi/change_material_name.py', 'green', 'plip'])
sub.wait()

with change_material_name.py :

import bpy
import sys
import os
from os.path import join

library_path = os.path.dirname(__file__)

if __name__ == '__main__':

    #target = sys.argv[4]
    #new_name = sys.argv[5]

    target = sys.argv[5]
    new_name = sys.argv[6]

    bpy.data.materials[target].name = new_name
    bpy.ops.wm.save_mainfile()
    bpy.ops.wm.quit_blender()

when I launch python ren.py, it only output an empty blender.crash.txt while it works like a charm if I remove the --background option.

I am running blender 2.77a and archlinux.

$\endgroup$

1 Answer 1

0
$\begingroup$

Shouldn't the blender file path be before --background argument?

import os
import sys
import subprocess

sub = subprocess.Popen(['blender', '/home/pegasi/green.blend', '--background', '--python', '/home/pegasi/change_material_name.py', 'green', 'plip'])
sub.wait()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .