NOTE : There are already two posts concerning this problem but I can't find an answer in them. I enclose the link that leads to it: Answers
Hy everyone,
I have in my script, a panel and an operator. I try to make sure that when the operator executes it puts a interne boolean variable to "True" and then make some elements of the panel display. I manage to access the operator's variable from the panel but I can't set this variable to "True" in the operator's execute. test_bool stays at "false".
Have a nice day.
The code looks like this :
def _build_bones_list():
#code...
class OP_ListBones(bpy.types.Operator) :
bl_idname = "object.oper_list_bones"
bl_label = "list bones!"
bl_description = "enregistre la liste des bones d'une armature"
test_bool=False
@classmethod
def poll(cls, context) :
#pass
return True
def execute(self, context) :
_build_bones_list()
self.test_bool= True #don't work
return {'FINISHED'}
class InterfacePanel (bpy.types.Panel) :
bl_label = "Parent Bones..."
bl_idname = "VIEW_3D_PT_PARENT_BONES"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Parent bones"
bl_description = "parentage robot mesh/bones"
_bool_=False
# --- interface_listener ---
def interface_listener(self) :
obj_select = bpy.context.selected_objects #list
obj_ = bpy.context.object #obj selected
l = self.layout
c=l.column(align = False)
if not obj_select or not obj_.type == "ARMATURE" :
l.label(text ="select an armature!!")
return
elif obj_.type == "ARMATURE":
#code...
c.operator(OP_ListBones.bl_idname)
#I'm trying to retrieve the boolean from the operator...
self._bool_ = OP_ListBones.test_bool
#code...
# --- interface_parent ---
def interface_parent(self) :
#code...
def draw(self, context) :
if not self._bool_ :
self.interface_listener()
elif self._bool_ :
self.interface_parent()