Call in a for loop
Closed this issue · 3 comments
Thanks for your amazing tools! It really helps and is integrated into my current production pipeline.
Have you tried call bpy.ops.object.train_test_cameras()
in a Python for loop? Seems that the detection of rendering process has some bug, which makes the for loop functioning bad.
For example, in this case I want to create datasets by setting different shape keys:
import bpy
import time
key_blocks = bpy.data.shape_keys['Key.001'].key_blocks
bs_names = list(key_blocks.keys())
scene = bpy.data.scenes['Scene']
print(bs_names)
for name in bs_names:
if name != 'Basis':
key_blocks[name].value = 0
for name in bs_names:
scene.save_path = "---"
print(name)
if name == 'Basis':
scene.ttc_dataset_name = 'bs_neutral'
# bpy.ops.object.train_test_cameras()
else:
key_blocks[name].value = 1
scene.ttc_dataset_name = f'bs_{name}'
bpy.ops.object.train_test_cameras()
key_blocks[name].value = 0
Only the last dataset in bs_names
is created, others don't render. It's related to the post_render
function in the helper.py
and also the 'INVOKE_DEFAULT' argument of the call to bpy.ops.render.render
.
Hi @dafei-qin,
Thanks for your message, I am glad to hear that BlenderNeRF is integrated into your production pipeline!
It seems to me that the issue might be with calling bpy.ops.render.render
, as you suggested. In the ttc_operator.py
file, I would recommend removing the 'INVOKE_DEFAULT'
argument from the bpy.ops.render.render
function as follows:
bpy.ops.render.render(animation=True, write_still=True)
The 'INVOKE_DEFAULT'
argument enables user interaction with the rendering window, which otherwise is not visible. Without it, the scene is being rendered in the background. This operator might however break or interfere with the for loop in some way.
If this does not solve the issue, I can look into it in more details. If you have a dummy blender file with different shape keys for an object that you want to render, feel free to share it here for me to investigate!
Yes exactly! I remove the INVOKE_DEFAULT
and also some minor modifications of the post_render
function, then it works as expected. Thanks again for the excellent plugin!
Glad it worked!