I want to achieve following functionality using python in blender -

  1. I want to open blender files located at a given path.
  2. Change textures of some objects in that blender file
  3. Set angle of the camera
  4. Render the scene and save the render at a given location. This will go in a loop for many blender scenes with proper lighting.

From above points I have achieved all points. But my problem is when i open a blender file using following script -

obj_root = pathlib.Path("I:/PythonBlender/first.blend") bpy.ops.wm.open_mainfile(filepath= str(obj_root))

the old file running the python scripts is closed and this new first.blend file is opened in blender. I want my python scripts to keep running and the scenes should load as an addon. and remove the addon scenes after rendering is finished. I also want to know what approach you will follow to achieve the above functionality with proper memory management and loading, unloading of textures and other files after rendering is done.

  • 1
    $\begingroup$ If you are running from the command line then this will not be a problem and you can have a sequence of Python scripts including one that "links" another .blend file as a library. See some examples I used github.com/robgithub/camera-track-endevour $\endgroup$ – rob Apr 16 at 11:38
  • $\begingroup$ Thankyou. I will checkout your solution. I am not running from command line. I am running scripting directly in blender scripting console $\endgroup$ – Gagandeep Singh Apr 17 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.