We’re rewarding the question askers & reputations are being recalculated! Read more.
52

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 -...


49

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. ...


33

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 ...


24

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 ...


24

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 ...


23

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 ...


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

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 ...


14

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 ...


14

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....


9

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

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 ...


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

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 ...


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

In windows OS you can open the console form the menu: Window->Toggle System Console: There you should be able to find information on your error. In your case you have a duplicated addon. This error can happen when you have two versions of the same addon as well. The duplicate could be in two places: On the programs folder in your system drive: C:\...


8

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 ...


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

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

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) ...


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

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


7

Example: You call on Blender 2.76 print(bpy.app.version_string) It will print to the console: 2.76 (sub 0) If you're looking to compare version numbers, its easier to do this using bpy.app.version which will always be a tuple of 3 ints, (major, minor, subversion), eg: (2, 76, 0) So you can compare the version number with regular comparison. if (2, ...


6

Here is an overview of (near) all command line options for Blender: https://docs.blender.org/manual/en/2.80/advanced/command_line/render.html blender -b file.blend -o //file -F JPEG -x 1 -f 1


6

Here's a second option, which I now believe is the best solution, as it is the most elegant and versatile that I've found so far. The solution is essentially an extension of the Compositing nodes Scale and FileOutput option. However the critical difference is the addition of an Image node being mixed with the scaled Render Output image before being piped ...


6

On Windows, Open a command prompt (Windows KeyR, type cmd and hit Enter) Drag the Blender shortcut or exe onto the promptC:\Users\Yourname>C:\Path\to\Blender.exe Add > %homepath%\Desktop\blender.log Hit return to start Blender with all console output redirected to blender.log on your Desktop. For Mac and Linux, have a look here: http://www.blender....


6

You go to Window>Console to open it:


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