def get_bone_rigs(obj, bone_name, halt_on_missing=False): """ Fetch all the rigs specified on a bone. """ rigs = [] rig_type = obj.pose.bones[bone_name].rigify_type rig_type = rig_type.replace(" ", "") if rig_type == "": pass else: # Gather parameters try: params = obj.pose.bones[bone_name].rigify_parameters[0] except (KeyError, IndexError): params = None # Get the rig try: rig = get_rig_type(rig_type).Rig(obj, bone_name, params) except ImportError: message = "Rig Type Missing: python module for type '%s' not found (bone: %s)" % (rig_type, bone_name) if halt_on_missing: raise MetarigError(message) else: print(message) print('print_exc():') traceback.print_exc(file=sys.stdout) else: rigs += [rig] return rigs
def get_bone_rigs(obj, bone_name, halt_on_missing=False): """ Fetch all the rigs specified on a bone. """ rigs = [] rig_type = obj.pose.bones[bone_name].rigify_type rig_type = rig_type.replace(" ", "") if rig_type == "": pass else: # Gather parameters try: params = obj.pose.bones[bone_name].rigify_parameters[0] except (KeyError, IndexError): params = None # Get the rig try: rig = get_rig_type(rig_type).Rig(obj, bone_name, params) except ImportError: message = "Rig Type Missing: python module for type '%s' not found (bone: %s)" % ( rig_type, bone_name) if halt_on_missing: raise MetarigError(message) else: print(message) print('print_exc():') traceback.print_exc(file=sys.stdout) else: rigs += [rig] return rigs
def draw(self, context): C = context id_store = C.window_manager bone = context.active_pose_bone collection_name = str(id_store.rigify_collection).replace(" ", "") rig_name = str(context.active_pose_bone.rigify_type).replace(" ", "") layout = self.layout # Build types list for i in range(0, len(id_store.rigify_types)): id_store.rigify_types.remove(0) for r in rigify.rig_list: collection = r.split('.')[0] if collection_name == "All": a = id_store.rigify_types.add() a.name = r elif r.startswith(collection_name + '.'): a = id_store.rigify_types.add() a.name = r elif collection_name == "None" and len(r.split('.')) == 1: a = id_store.rigify_types.add() a.name = r # Rig type field row = layout.row() row.prop_search(bone, "rigify_type", id_store, "rigify_types", text="Rig type:") # Rig type parameters / Rig type non-exist alert if rig_name != "": if len(bone.rigify_parameters) < 1: bone.rigify_parameters.add() try: rig = get_rig_type(rig_name) rig.Rig except (ImportError, AttributeError): row = layout.row() box = row.box() box.label(text="ALERT: type \"%s\" does not exist!" % rig_name) else: try: rig.Rig.parameters_ui except AttributeError: pass else: col = layout.column() col.label(text="Options:") box = layout.box() rig.Rig.parameters_ui(box, C.active_object, bone.name)
def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": try: rig = get_rig_type(self.metarig_type).Rig create_sample = rig.create_sample except (ImportError, AttributeError): print("Rigify: rig type has no sample.") else: create_sample(context.active_object) bpy.ops.object.mode_set(mode='EDIT') return {'FINISHED'}
def draw(self, context): C = context id_store = C.window_manager bone = context.active_pose_bone collection_name = str(id_store.rigify_collection).replace(" ", "") rig_name = str(context.active_pose_bone.rigify_type).replace(" ", "") layout = self.layout # Build types list for i in range(0, len(id_store.rigify_types)): id_store.rigify_types.remove(0) for r in rigify.rig_list: # collection = r.split('.')[0] # UNUSED if collection_name == "All": a = id_store.rigify_types.add() a.name = r elif r.startswith(collection_name + '.'): a = id_store.rigify_types.add() a.name = r elif collection_name == "None" and len(r.split('.')) == 1: a = id_store.rigify_types.add() a.name = r # Rig type field row = layout.row() row.prop_search(bone, "rigify_type", id_store, "rigify_types", text="Rig type:") # Rig type parameters / Rig type non-exist alert if rig_name != "": if len(bone.rigify_parameters) < 1: bone.rigify_parameters.add() try: rig = get_rig_type(rig_name) rig.Rig except (ImportError, AttributeError): row = layout.row() box = row.box() box.label(text="ALERT: type \"%s\" does not exist!" % rig_name) else: try: rig.Rig.parameters_ui except AttributeError: pass else: col = layout.column() col.label(text="Options:") box = layout.box() rig.Rig.parameters_ui(box, C.active_object, bone.name)
def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": use_global_undo = context.user_preferences.edit.use_global_undo context.user_preferences.edit.use_global_undo = False try: rig = get_rig_type(self.metarig_type).Rig create_sample = rig.create_sample except (ImportError, AttributeError): print("Rigify: rig type has no sample.") else: create_sample(context.active_object) finally: context.user_preferences.edit.use_global_undo = use_global_undo bpy.ops.object.mode_set(mode='EDIT') return {'FINISHED'}