diff options
Diffstat (limited to 'rigify/utils/rig.py')
-rw-r--r-- | rigify/utils/rig.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rigify/utils/rig.py b/rigify/utils/rig.py index fa55c1aa..7969a34f 100644 --- a/rigify/utils/rig.py +++ b/rigify/utils/rig.py @@ -91,6 +91,36 @@ def upgradeMetarigTypes(metarig, revert=False): # Misc #============================================= + +def rig_is_child(rig, parent, *, strict=False): + """ + Checks if the rig is a child of the parent. + Unless strict is True, returns true if the rig and parent are the same. + """ + if parent is None: + return True + + if rig and strict: + rig = rig.rigify_parent + + while rig: + if rig is parent: + return True + + rig = rig.rigify_parent + + return False + + +def get_parent_rigs(rig): + """Returns a list containing the rig and all of its parents.""" + result = [] + while rig: + result.append(rig) + rig = rig.rigify_parent + return result + + def get_resource(resource_name): """ Fetches a rig module by name, and returns it. """ |