I’m sure this will have been written somewhere, but I can’t find it at the moment.
I have a script which works. I want to run blender from a command line, have it find this script, run it, then exit.
Originally I’d have liked blender to run in --background mode, but for some reason this causes Cycles to render me a nice grey box, so for the moment I’m running it as usual, with the GUI and everything, using this command:
blender.exe autoGen.blend --file xml.xml
So autoGen.blend is the blendfile with my script in it, and xml.xml is a file that the script uses. As is, this works adequately.
Couple of cosmetic problems: blender bitches about the “–file xml.xml” because it doesn’t know what it means. Is there a way I can tell it that everything’s fine?
Secondly, the program opens but doesn’t close. When the script finishes, blender’s gui appears and lets me edit autoGen.blend. This is a problem because tomorrow I’m handing the script over to someone else with no knowledge of blender. I don’t want them to keep having to close windows and I certainly don’t want them to be able to poke around inside the blend file without knowing what they’re doing.
What I have at the moment is ‘Auto run python scripts’ checked in the User Prefs, and ‘Register’ checked at the bottom of the script’s text window. I have no understanding as to why, but that makes the thing open and run. Where do I go from here?
I have no clue if this would actually work, but everything in the Blender UI is supposed to be accessible though the Python interface. Have you check “bpy.ops” to see if there is a command that ties to the “Quit” button. It seems like after your script has finished running you should be able to tell Blender to Quit.
As far as the command line stuff goes, I don’t have much experience there.
you may re-route the stderr and stdout output to a dummy file and delete this later or directly to /dev/null
and a short quit-python-file to only run a special blend-file could be this:
import bpy
bpy.ops.wm.quit_blender()
saved as quit.py
and the start of blender in the blender-directory:
the python script could be something more usefull, maybe like doing a render of an image and save this …
EDIT: i personally think to hide error-messages, status-messages is a bad habit, because no one could see if something goes totally wrong … but some people like to be blinded …
test-dr: the main reason I want to hide it is because it’s eclipsing my own script’s output.
This means I can’t just pipe into a text file, because I want the piping to start halfway through (ie, only start hiding blender’s output when my own script has finished.)