Changeset View
Changeset View
Standalone View
Standalone View
rigify/utils/rig.py
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | def get_metarig_module(metarig_name, path=METARIG_DIR): | ||||
| """ | """ | ||||
| name = ".%s.%s" % (path, metarig_name) | name = ".%s.%s" % (path, metarig_name) | ||||
| submod = importlib.import_module(name, package=MODULE_NAME) | submod = importlib.import_module(name, package=MODULE_NAME) | ||||
| importlib.reload(submod) | importlib.reload(submod) | ||||
| return submod | return submod | ||||
| def attach_persistent_script(obj, script): | |||||
| """Make sure the ui script always follows the rig around""" | |||||
| skip = False | |||||
| driver = None | |||||
| if not obj.animation_data: | |||||
| obj.animation_data_create() | |||||
| for fcurve in obj.animation_data.drivers: | |||||
| if fcurve.data_path == 'pass_index': | |||||
| driver = fcurve.driver | |||||
| for variable in driver.variables: | |||||
| if variable.name == script.name: | |||||
| skip = True | |||||
| break | |||||
| break | |||||
| if not skip: | |||||
| if not driver: | |||||
| fcurve = obj.driver_add("pass_index") | |||||
| driver = fcurve.driver | |||||
| variable = driver.variables.new() | |||||
| variable.name = script.name | |||||
| variable.targets[0].id_type = 'TEXT' | |||||
| variable.targets[0].id = script | |||||
| def connected_children_names(obj, bone_name): | def connected_children_names(obj, bone_name): | ||||
| """ Returns a list of bone names (in order) of the bones that form a single | """ Returns a list of bone names (in order) of the bones that form a single | ||||
| connected chain starting with the given bone as a parent. | connected chain starting with the given bone as a parent. | ||||
| If there is a connected branch, the list stops there. | If there is a connected branch, the list stops there. | ||||
| """ | """ | ||||
| bone = obj.data.bones[bone_name] | bone = obj.data.bones[bone_name] | ||||
| names = [] | names = [] | ||||
| ▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines | |||||