Hy everyone,
In my code I created a PropertyGroup called: Operator_LB_Settings
It defaults to two booleans, which are basically “False”.
Only in my code without having done anything this one are True. Did you ever get that?
import bpy
# ---------------------------------------------------
# PROPERTY
# bones number
bpy.types.WindowManager.bones_nbr = bpy.props.IntProperty(name="bones", default=0)
# Armature name
bpy.types.WindowManager.armature_select = bpy.props.StringProperty(name = "Armature", default="NONE")
# Boolean : valid that the operator OP_ListBones is executed
class Operator_LB_Settings(bpy.types.PropertyGroup):
executed: bpy.props.BoolProperty(description='Operator has been executed.',
default=False)
success: bpy.props.BoolProperty(description='Operator executed successfully.',
default=False)
# ---------------------------------------------------
# UIList customizes : 1,2,register CustomProp
# 1 CustomProp
class CustomProp(bpy.types.PropertyGroup):
id : bpy.props.IntProperty() #TEMP
name : bpy.props.StringProperty(name="Test Prop",description='UIList property', default="Unknown")#TEMP
# 2 La classe UIList:
class EX_UL_items(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
layout.prop(item, "name", text="", emboss=False, translate=False)
def invoke(self, context, event):
pass
# ---------------------------------------------------
# OPListBones : register the bones of an armature
def _build_bones_list():
print("function : _build_bones_list() launch")
#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"
#def draw(self):
#print("draw")
@classmethod
def poll(cls, context) :
return True
def execute(self, context) :
_build_bones_list()
return {'FINISHED'}
# ---------------------------------------------------
# OPParentBs : parente les meshs avec le bones seclectionne
def ParentBones() :
print("function : ParentBones() launch")
class OP_ParentBones(bpy.types.Operator) :
bl_idname = "object.oper_prt_bones"
bl_label = "parent bones!"
bl_description = "parente les meshs avec le bones seclectionne"
@classmethod
def poll(cls, context) :
pass
def execute(self, context) :
ParentBones()
return {'FINISHED'}
def invoke(self, context, event) :
pass
# ---------------------------------------------------
# PANEL
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"
def draw(self, context) :
print("cl InterfacePanel -- > bpy.context.scene.op_bl_settings.executed : "+ str(bpy.context.scene.op_bl_settings.executed)) #True
print("cl InterfacePanel -- > bpy.context.scene.op_bl_settings.success : "+ str(bpy.context.scene.op_bl_settings.success)) #true
# ---------------------------------------------------
# REGISTER
def register() :
# ---------------
# CustomProp
bpy.utils.register_class(EX_UL_items)
bpy.utils.register_class(CustomProp)
#bpy.types.Scene.bones_map = bpy.props.CollectionProperty(type=CustomProp)
bpy.types.Scene.bones_map = bpy.props.PointerProperty(type=CustomProp)
bpy.types.Scene.bones_map_index = bpy.props.IntProperty()
# ---------------
bpy.utils.register_class(Operator_LB_Settings)
bpy.types.Scene.op_bl_settings = bpy.props.PointerProperty(type=Operator_LB_Settings)
bpy.utils.register_class(InterfacePanel)
bpy.utils.register_class(OP_ListBones)
bpy.utils.register_class(OP_ParentBones)
def unregister() :
bpy.utils.unregister_class(Operator_LB_Settings)
bpy.utils.unregister_class(InterfacePanel)
bpy.utils.unregister_class(OP_ListBones)
bpy.utils.unregister_class(OP_ParentBones)
if __name__ == "__main__" :
register()
Good journey,