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.