<aside> 🔗 Twitter / Website / Newsletter / Gumroad
</aside>
# Run Blender and enter REPL
$ blender --python-console
# Run a script from command line
$ blender model.blend -P script.py
# Run script in background (without UI)
$ blender model.blend -b -P script.py
# Passing custom command line arguments
# Anything after -- will be ignored by Blender
$ blender model.blend -b -P script.py -- arg1 arg2
# And you can access them using sys.argv
>>> import sys
>>> sys.argv[6]
# NOTE: You need to replace 'blender' with full path to
# the Blender executable if it is not on PATH
$ path/to/blender --python-console
$ path/to/blender -P script.py
$ path/to/blender -b -P script.py
$ path/to/blender -P script.py -- arg1 arg2
$ path/to/blender --python-exit-code <code>
bpy.context.active_object
bpy.context.view_layer.objects.active = object_to_set_active