i have a GUI made in pyside that render a blender file. This GUI have a resolution options to control this before render scene.... i have this code in PyCharm, i need to run this code without open blender.
if resolutionWidth != 0:
bpy.context.scene.render.resolution_x = resolutionWidth
if resolutionHeight != 0:
bpy.context.scene.render.resolution_y = resolutionHeight
# Override Resolution Scale
#SCALE = batchRender_UI.resolution_scaleUI()
if SCALE != 0:
bpy.context.scene.render.resolution_percentage = SCALE
You can run a blender's python script without opening blender's GUI in background from command line. Go to directory where blender is installed, open terminal/cmd over there and type following command -
blender -b -P path/to/your/script.py
The flag -b tells blender to run in background. -P tells to run a python script using blender's python. If you want to open blender's GUI and run py script then run the following code:
blender -P path/to/your/script.py
While running as subprocess use the following code:
import subprocess
subprocess.run(['blender', '-b', '-P', 'path/to/your/script.py'])
In case you want more interactive control over Blender, you can build Blender as a python module .
This is a build option to be able to import blender into python and access its modules. [...] This is mainly limited to features which can be usable in background mode, so you cant for instance do OpenGL preview renders.
Be aware that since Blender uses a copyleft license , depending on how you want to use and distribute your app, this may or may not be acceptable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.