Changeset View
Changeset View
Standalone View
Standalone View
rigify/utils/layers.py
| Show All 15 Lines | |||||
| # | # | ||||
| #======================= END GPL LICENSE BLOCK ======================== | #======================= END GPL LICENSE BLOCK ======================== | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| import bpy | import bpy | ||||
| ORG_LAYER = [n == 31 for n in range(0, 32)] # Armature layer that original bones should be moved to. | |||||
| MCH_LAYER = [n == 30 for n in range(0, 32)] # Armature layer that mechanism bones should be moved to. | |||||
| DEF_LAYER = [n == 29 for n in range(0, 32)] # Armature layer that deformation bones should be moved to. | |||||
| ROOT_LAYER = [n == 28 for n in range(0, 32)] # Armature layer that root bone should be moved to. | |||||
| def get_layers(layers): | def get_layers(layers): | ||||
| """ Does its best to extract a set of layers from any data thrown at it. | """ Does its best to extract a set of layers from any data thrown at it. | ||||
| """ | """ | ||||
| if type(layers) == int: | if type(layers) == int: | ||||
| return [x == layers for x in range(0, 32)] | return [x == layers for x in range(0, 32)] | ||||
| elif type(layers) == str: | elif type(layers) == str: | ||||
| s = layers.split(",") | s = layers.split(",") | ||||
| l = [] | l = [] | ||||
| Show All 32 Lines | def get(self, params): | ||||
| if getattr(params, self.toggle_option): | if getattr(params, self.toggle_option): | ||||
| return list(getattr(params, self.layers_option)) | return list(getattr(params, self.layers_option)) | ||||
| else: | else: | ||||
| return None | return None | ||||
| def assign(self, params, bone_set, bone_list): | def assign(self, params, bone_set, bone_list): | ||||
| layers = self.get(params) | layers = self.get(params) | ||||
| if isinstance(bone_set, bpy.types.Object): | |||||
| bone_set = bone_set.data.bones | |||||
| if layers: | if layers: | ||||
| for name in bone_list: | for name in bone_list: | ||||
| bone = bone_set[name] | bone = bone_set[name] | ||||
| if isinstance(bone, bpy.types.PoseBone): | if isinstance(bone, bpy.types.PoseBone): | ||||
| bone = bone.bone | bone = bone.bone | ||||
| bone.layers = layers | bone.layers = layers | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||