Search code examples
pythonsubprocessblenderpopen

What tokens to use with Popen for running a blender script?


I have the following command which I am trying to run from python using Popen, however I am not sure what should be the tokens to be passed to it.

blender object.blend --background --python blenderObj.py -- box.obj object.obj

I tried various combinations including separately passing each of the tokens and also passing "--" and "background" together, but can't make it. Please help.

EDIT [Solution]: as suggested by Ja8zyjits in the comments below, passing the whole command as a single string worked.


Solution

  • this will do the job for you, try this.

    import subprocess
    p = subprocess.Popen(["blender object.blend --background --python blenderObj.py --box.obj object.obj"], stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True)
    out, err = p.communicate()