From bdbf5669d586ab7f5a36c2d7b492e53897ffaa16 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 11 Oct 2018 15:40:46 +0200 Subject: [PATCH] use context.active_object instead of context.object in poll function --- ops_snapping.py | 84 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/ops_snapping.py b/ops_snapping.py index ebfba42..2eb406e 100644 --- a/ops_snapping.py +++ b/ops_snapping.py @@ -43,8 +43,10 @@ class Operator_Torso_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -96,8 +98,10 @@ class Operator_Torso_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -153,8 +157,10 @@ class Operator_Torso_Snap_INV_UP(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -216,8 +222,10 @@ class Operator_Torso_Snap_UP_INV(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -274,8 +282,10 @@ class Operator_Head_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -326,8 +336,10 @@ class Operator_Head_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -382,8 +394,10 @@ class Operator_Arm_L_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -469,8 +483,10 @@ class Operator_Arm_L_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -578,8 +594,10 @@ class Operator_Arm_R_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -665,8 +683,10 @@ class Operator_Arm_R_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -774,8 +794,10 @@ class Operator_Leg_L_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -859,8 +881,10 @@ class Operator_Leg_L_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -979,8 +1003,10 @@ class Operator_Leg_R_Snap_IK_FK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object @@ -1064,8 +1090,10 @@ class Operator_Leg_R_Snap_FK_IK(bpy.types.Operator): @classmethod def poll(cls, context): - if context.active_object is not None: - return (bpy.context.object.type=='ARMATURE' and context.mode=='POSE') + if not bpy.context.active_object: + return False + else: + return (bpy.context.active_object.type=='ARMATURE' and context.mode=='POSE') def execute(self, context): arm = bpy.context.active_object