62

Command-line / subprocess You can use subprocess to run blender (like any other application) from python. Use the -b / --background switch to run blender in the backgroud (GUI-less). Use the -P <filename> / --python <filename> switch to load desired python script. Or use --python-console to run python from stdin. Example: blender --background -...


57

Yes, Blender's Python can read command line arguments. In summary: Python can read all arguments passed to Blender via sys.argv(just the same as you would in Python) Blender will ignore all arguments after: --(double dash with no arguments, as documented in the --help message) Scripts can check for -- in sys.argv and ignore all arguments beforehand. ...


34

Yes, you can use blender -b file_name.blend -x 1 -o //file -F AVI_JPEG -s 001 -e 250 -S scene_name -a -b: tells blender to run in background -x: is used to add an extension to the movie -o: sets the directory + Target image file -F: sets the output image type -s: 001 -e 250 -a set the start frame to 001 and end frame to 250. Important: You can use -s ...


29

All what Aldrik wrote, and more Blender Python API Tips and Tricks Updated From official Blender documentation: For scripts that are not interactive it can end up being more efficient not to use Blenders interface at all and instead execute the script on the command line. blender --background --python myscript.py You might want to run this with a ...


26

Yes you can, This will render a single frame blender --background filename.blend --render-output //test_ --engine CYCLES --render-format PNG --use-extension 1 --render-frame 5 This will output a file named test_0005 While experimenting, I more or less substituted CYCLES with the parameters I found here. You can check the link to see what they mean and or ...


24

For starter, there's already quite a bit of discussion about command-line rendering in this forum, like for this question. You do need scripting for such automation. Here's a script containing just the basics, elaborated below: Script: # Run as: blender -b <filename> -P <this_script> -- <image_path> import bpy, sys, os # Assume the last ...


16

Command line One way is to set the properties from the gui, save the file, then render. The settings will be preserved for rendering from the command line. Note that (as already mentioned by iKlsR) you can set the render output format from the command line with -F: Format Options: -F or --render-format <format> Set the render format, Valid options ...


16

Please invest time into researching about the Blender API and Python interface, before asking questions! image = bpy.ops.mesh.primitive_cube_add(radius=1, location = (0,0,0)) This line does not make any sense at all. primitive_cube_add is an operation, which returns a status set. In this case it returns {FINISHED}. {FINISHED} is most definitely not a ...


15

It is possible, in a round-about way. Operator render.opengl() needs OpenGL display context, i.e. Blender's window, to be opened. Hence, we can't do UI-less rendering using -b command switch. We'll need to do it through a script: import bpy import sys # read argument from sys.argv from bpy.app.handlers import persistent @persistent def ...


15

Execute the following command in the terminal, then open a new terminal window and the blender command should work as expected: echo "alias blender=/Applications/Blender/blender.app/Contents/MacOS/blender" >> ~/.profile What this command does is add the following line to the end of /Users/SteveW/.profile: alias blender=/Applications/Blender/blender....


15

Sounds like a job for Command Line Rendering. Sounds intimidating if you've never done it, but it's a simple matter of stealing someone's template and adjusting the parameters: Windows: blender -b "C:\path\to\file.blend" -x 1 -a Linux/Mac: blender -b "/path/to/file.blend" -x 1 -a That's the simplest form of it which will use all the settings in the blend ...


15

bpy.app.version_string Test using the python console: >>> bpy.app.version_string '2.83.2' Usage within a script file: import bpy print(bpy.app.version_string) which will print the actual version to the system console window: 2.83.2 bpy.app.version If you're looking to compare version numbers, it's easier to do this using bpy.app.version which ...


13

Using python you can install an addon with bpy.ops.wm.addon_install(), you can then enable the addon with bpy.ops.wm.addon_enable() and disable it with bpy.ops.wm.addon_disable(). To keep the addon enabled every time you start blender you save your settings with bpy.ops.wm.save_userpref() For addon_install you give it the filepath to the addon, this is the ...


11

I created a little utility addon that let's you easily run Text datablocks of your .blend (doesn't need to be saved) in the Python Console. Errors will show up there:Run Script in PyConsole (Menu) You may also check out the Script Runner addon: http://goodspiritgraphics.com/software/products/script-runner-addon/ It should be possible to run scripts like ...


10

This information is stored in the blend files header, so you can find out without having to load Blender at all. This has the advantage you can scan a directory of 100's (or 1000's) of blend files in a very short time (a few seconds even if the files are large). Blender comes with a script in scripts/modules/blend_render_info.py which can extract this data ...


9

No, Blender has no command line arguments to return the number of frames in the scene, however you can use a script. Here is a script as mentioned by CoDEmanX above: import bpy scene = bpy.context.scene print("Scene %r frames: %d..%d = %d" % (scene.name, scene.frame_start, scene.frame_end, scene.frame_end - scene.frame_start + 1)) # frame_end is included ...


9

As iKlsR wrote, you can use command-line options to render scenes in batch. If you have saved all the necessary settings such as the start and end frames, the output format, and the output file names in your blend file and all you want is just render the animations in specific scenes, then you do not have to specify many command-line options and you can do ...


9

On windows just run blender from Command Prompt: Win Key+R In field type cmd and hit OK. Inside the console navigate to your blender.exe with command cd c:\Program Files\Blender Foundation\Blender\ (or whatever your path is) instead you can also navigate to the folder in the Explorer and SHIFT+Rightclick on the Folder and select Open Comand Promt here ...


9

Figured it out! here's how to use the python API to set it. # X, Y, and Z location to set default_cube.location = 0.0, 0.0, 0.0 # Set the keyframe with that location, and which frame. default_cube.keyframe_insert(data_path="location", frame=1) # do it again! default_cube.location = 3.0, 2.0, 1.0 # setting it for frame 10 default_cube.keyframe_insert(...


9

Below is an example add-on that adds a button to the text editor for this purpose. Clearing the console is done with the platform specific commands cls for Windows and clear for Linux and macOS. Both are executed through os.system(command) bl_info = { "name": "Clear System Console", "author": "Robert Guetzkow",...


8

I have built a script that follows a set of instructions, getting lots of textures. The script is filling the sides of a cube with textures, with 2 methods, map4 cube faces and map1cubeface. It first looks for inside the directories of a folder, jpg images, and then allocate them to the faces, then unwrap, then render. Hope you understand. Here you go: ...


8

Both these arguments are mainly for developers. --verbose is currently only used by libmv (camera tracking), however we will likely use in the future to control other output. --debug-value is mainly for developers to test alternative behavior, from Python you can access it from bpy.app.debug_value from C/C++ you can access it from G.debug_value (with ...


8

It seems that the order is as follows (in order from weakest to strongest): Startup .blend settings (does not override anything) --factory-startup will override all startup .blend preferences (including auto exec), but the default setting for auto exec is disabled (disallowing auto execution globally). -y (--enable-autoexec) enables -Y (--disable-autoexec) ...


8

The solution is to start blender with --python-console, see the user manual for Python command line args.


7

AFAIK, there is no option to set tile sizes directly from the command line. However, you could use the python api to do this, and execute a python script in blender from the command line. (see this question) To set tile sizes from python, you can use bpy.context.scene.render.tile_x and bpy.context.scene.render.tile_y. Tile order can be set with bpy.data....


7

If you do not want to restart Blender to see the messages sent to stdout or stderr, you can always run your script in blenders built-in python console. This is possible, because you can access all the linked text files of a .blend file you loaded through the bpy.data.texts dictionary. To get a list of all the text files available you can use the following ...


7

On Linux/Ubuntu its ./blender > myLog123.txt from the working directory. ./blender &> myLog123.txt to include Stderr. In Python you can do import sys file = open(filepath, "w") sys.stdout = file #... #... sys.stdout = sys.__stdout__ #reset file.close() to catch the console output while your script is running.


7

If you name your script *.py in the text editor you can import it in the console as a module. Beware - after you imported the script for the first time you can't import it again. If you make changes to the module you can use imp.reload or importlib.reload (for blender versions > 2.71 using python 3.4)


7

You go to Window>Console to open it:


Only top voted, non community-wiki answers of a minimum length are eligible