From ff1ac1ca8d8d4dcbb3cad50480048464ac7e8210 Mon Sep 17 00:00:00 2001 From: miquelcampos Date: Mon, 29 Apr 2024 08:55:23 +0900 Subject: [PATCH] Rigbits: Mirror control shapes. Adding old logic if old implementation fails. This allows to mirror ctl shapes if the ctl don't have shifter metadata --- .../scripts/mgear/rigbits/mirror_controls.py | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/release/scripts/mgear/rigbits/mirror_controls.py b/release/scripts/mgear/rigbits/mirror_controls.py index 1c36812e..39f73c89 100644 --- a/release/scripts/mgear/rigbits/mirror_controls.py +++ b/release/scripts/mgear/rigbits/mirror_controls.py @@ -12,19 +12,27 @@ def __init__(self): @staticmethod def get_opposite_control(node): - side_l = node.attr("L_custom_side_label").get() - side_r = node.attr("R_custom_side_label").get() - side = node.attr("side_label").get() - - target_name = None - if side == "L": - target_name = node.name().replace(side_l, side_r) - elif side == "R": - target_name = node.name().replace(side_r, side_l) - - if target_name and pm.objExists(target_name): - return pm.PyNode(target_name) - return None + try: + side_l = node.attr("L_custom_side_label").get() + side_r = node.attr("R_custom_side_label").get() + side = node.attr("side_label").get() + + target_name = None + if side == "L": + target_name = node.name().replace(side_l, side_r) + elif side == "R": + target_name = node.name().replace(side_r, side_l) + + if target_name and pm.objExists(target_name): + return pm.PyNode(target_name) + return None + except pm.MayaAttributeError: + # try to get the opposite control using the old logic + target_name = mgear.core.string.convertRLName(node.name()) + target = None + if pm.objExists(target_name): + target = pm.PyNode(target_name) + return target @staticmethod def get_specific_side_controls(side="L"):