1
$\begingroup$

I am on Windows 10 and I am using Blender 3.4.1 with a simple geometry node set-up in my blend file geonodes.blend. In this file, my render settings are set to my liking (Cycles is used and JPEG is the output format). A single JPEG file should be obtained (I am not running a sequential render).

I wish to alter the float values for Input_1 and Input_2 (both defaulted to zero) of my geometry node modifier via a python script called update_values.py. However, I wish to do that outside of Blender itself by using the command prompt.

In command prompt, I run:

cd /D D:\Projects\blender\geonodes
blender ./geonodes.blend -b -P ./update_values.py

with update_values.py being:

from bpy import context as C
S = C.scene
R = S.render
CO = C.object
from bpy import ops as O
OR = O.render

CO.modifiers["GeometryNodes"]["Input_1"] = 10
CO.modifiers["GeometryNodes"]["Input_2"] = 20

R.filepath = "//renders/output/updated_inputs."
OR.render(use_viewport = True, write_still=True)

In the command prompt, no error messages are returned and yet, when I open updated_inputs.jpg, the image output has clearly ignored the updated values for Input_1 and Input_2.

Is there something I am doing wrong? Any help or pointers on this would be greatly appreciated.

$\endgroup$
2

2 Answers 2

1
$\begingroup$

post my solution here, the bug report from two years ago.

I had the same issue and I solved it by doing it in two steps:

  1. Running the Python script from the command line without rendering the content. this step includes changing the values, baking all dynamics with the new values in the script, and saving the file to a new .blend file, or the same. Note: you don't render in step #1, only prepare the content.
  2. Run the new saved file and just render it from CLI (command line).

It is working for me and solved my issue. Here you can see the full commands added for baking the scene.

$\endgroup$
-2
$\begingroup$

After you are done with the modifier,you need to bpy.context.object.data.update().

Note that it does not work for too low version of blender

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .