I have the following code snippet which I am trying to run two operators from an addon:
import bpy
# create needed operators
ng = bpy.data.node_groups['rad_sim']
image_node = ng.nodes.new(type="No_Li_Im")
falsecolor_node = ng.nodes.new(type="No_Li_Fc")
# image_node has a parameter run which returns 0 while not active and 1 while active
print("Image_node status: {}".format(image_node.run) # this gives me 0 as expected
override = {'node':image_node}
bpy.ops.node.radimage(override, 'INVOKE_DEFAULT')
print("Image_node status2: {}".format(image_node.run)) # this gives me 1 as expected
while True:
if image_node.run:
print("Image_node status: {}".format(image_node.run)) # this gives me 1 as expected
continue
else:
break
override = {'node':falsecolor_node}
bpy.ops.node.livifc(override, 'INVOKE_DEFAULT')
image_node
is a modal operator and has a parameter run
which returns 0 while not active and 1 while active. Now in order to have the falsecolor_node
operator successfully running I need to have image_node
operator finished first. Thus, I've tried to introduce a while
loop which test each time whether the the image_node
operator is finished or not. However, what happens is that the execution of the image_node
operator hangs while I am in the while
loop. My guess is that I am running into Python's interpreter lock or something, my question is how I could bypass this somehow if possible. I was thinking to make my code above as a modal operator but I am not quite sure how to do that (not that much experience with creating my own custom operators). Thus, any help would be appreciated.
Thanks.