def mesh(self, context): layout = self.layout obj = context.active_object if not (Is.mesh(obj) and Is.armature(obj.parent)): return False scn = context.scene if hasattr(scn, 'DazShowRigging'): layout.prop(scn, 'DazMannequinGroup', text="") idname = 'daz.add_mannequin_macro' # op = layout.operator(idname, text="Full Macro") layout.operator_menu_hold(idname, menu='MACRO_MT_add_mannequin_full', text="Add Mannequin (Full Macro)" + mannequin.head).macro = True layout.operator_menu_hold(idname, menu='MACRO_MT_add_mannequin_only', text="Add Mannequin" + mannequin.head) # op.head = 'SOLID' # op.macro = True # layout.operator(idname, text="Solid").head = 'SOLID' # layout.operator(idname, text="Jaw").head = 'JAW' # layout.operator(idname, text="Full").head = 'FULL' layout.operator('object.data_transfer_mannequin_preset', icon='OUTLINER_DATA_MESH') layout.operator('object.data_transfer_materials', icon='MATERIAL') return True
def rig(self, context): layout = self.layout rig = meta = rigify = False count = 0 for daz in context.selected_objects: if not Is.armature(daz): continue # elif daz.data.get('rig_id') is not None: # rigify = True # elif daz.data.rigify_layers: # meta = True # rig = True count += 1 if count >= 2: layout.operator('daz.merge_rigs') break for op in ('macro.daz_to_metarig', 'macro.daz_to_metarig_weights', 'macro.generate_rigify', 'macro.meta_from_rigify', 'macro.meta_to_rigify', 'macro.rigify_to_meta'): if eval(f'bpy.ops.{op}.poll()'): layout.operator(op) rig = True return (rig or (count >= 2))
def poll(cls, context): ob = context.object if Is.armature(ob) and ob.mode in ('POSE', 'EDIT'): return Get.selected(context, ob) if not bpy.ops.paint.weight_from_bones.poll(context.copy()): return if Is.mesh(ob) and (ob.mode == 'WEIGHT_PAINT'): for mod in ob.modifiers: if (mod.type == 'ARMATURE') and (mod.object in Get.objects(context)[:]): if mod.object.mode == 'POSE': return True
def execute(self, context): mannequin.head = f" ({self.head.title()})" objects = list() for obj in context.selected_objects: if Is.mesh(obj) and Is.armature(obj.parent): inst = self.convert(context, obj) objects.append(inst) for obj in reversed(objects): Set.active_select(context, obj, isolate=False) return {'FINISHED'}
def poll(self, context): for obj in context.selected_objects: if Is.mesh(obj) and Is.armature(obj.parent): return True
def execute(self, context): # active = Get.active(context) for rig in context.selected_editable_objects: if not Is.armature(rig): continue mode = rig.mode if not Set.mode(context, 'EDIT', rig): Set.mode(context, mode, rig) continue mirror = rig.data.use_mirror_x rig.data.use_mirror_x = False # Set.active(context, rig) bones = Get.selected_edit_bones(context, rig) links = [] # empty list for bone in bones: if bone.parent and not Is.connected( bone): # prevent root-error link = rig.data.edit_bones.new( 'COR-%s<>%s' % (bone.parent.name, bone.name)) link.tail = bone.head link.head = bone.parent.tail link.layers = bone.layers # link.layers = utils.layer(30) # # layer 28 = IK # # Layer 32 = Gap<>fillers # if (rig.data.rigify_layers): # link.layers = [True if index in (31,) else False for index, layer in enumerate(range(32))] link.use_deform = False link.parent = bone.parent bone.parent = link connect(link) connect(bone) link.use_connect = True bone.use_connect = True # bpy.ops.object.mode_set(mode='POSE');bpy.ops.object.mode_set(mode='EDIT'); links.append(link.name) # bone = rig.pose.bones[link.name] # bone.lock_ik_x = True # bone.lock_ik_y = True # bone.lock_ik_z = True '''def gap(bone): #bpy.ops.object.mode_set(mode='POSE'); bone = C.active_object.pose.bones[bone] bone.lock_ik_x=True; bone.lock_ik_y=True; bone.lock_ik_z=True; #bpy.ops.object.mode_set(mode='EDIT'); try: bone.lock_ik_x=True; bone.lock_ik_y=True; bone.lock_ik_z=True; link = link.name except: continue ''' elif Is.connected(bone): bone.use_connect = True else: # root-ctrl-bone continue "or this will create a parent for a 'root' bone" link = rig.data.edit_bones.new('COR-%s<>%s' % (bone.name, bone.name)) link.tail = bone.tail link.head = bone.head link.layers = utils.layer(30) # link.layers = bone.layers link.use_deform = False link.show_wire = True bone.parent = link links.append(link.name) rig.data.use_mirror_x = mirror Set.mode(context, 'POSE', rig) for link in links: link = rig.pose.bones.get(link, None) if link is None: # if bone's head+tail are the same, it'll cancel itself out continue links = link.name.replace('COR-', '', 1).split('<>') # linked = rig.pose.bones.get(links[1], None) if self.lock_ik: link.ik_stiffness_x = 1 link.ik_stiffness_y = 1 link.ik_stiffness_z = 1 if (links[0] != links[1]): # Parent <x> Child link.lock_ik_x = True link.lock_ik_y = True link.lock_ik_z = True link.lock_location = [True, True, True] link.lock_rotation_w = True link.lock_rotation = [True, True, True] link.lock_scale = [True, True, True] else: # Original bone was copied for a control bone print("Original bone was copied for a control bone") # try: # linked.lock_ik_x=True; linked.lock_ik_y=True; linked.lock_ik_z=True; # linked.ik_stiffness_x=1; linked.ik_stiffness_y=1; linked.ik_stiffness_z=1; # if not 'WGT-hips' in bpy.data.objects: # bpy.context.scene.quickrig.create_wgt = 'hips' # bpy.ops.quickrig.create_widgets() # widget = bpy.data.objects['WGT-hips'] # link.custom_shape = widget # #have the bone follow the original #link.custom_shape_transform = rig.pose.bones[links[1]] # link.use_custom_shape_bone_size = False # con = widget.constraints.new('COPY_TRANSFORMS') # con.target = rig; con.subtarget = link.name; # widget.layers[9] = True; layers = 0 # for layer in widget.layers: # if layers != 9: layer = False # except: pass ... def bgroup(name): bgroups = rig.pose.bone_groups if name in bgroups: group = bgroups[name] else: group = bgroups.new(name=name) group.color_set = 'CUSTOM' black = ((0.0, 0.0, 0.0)) select = ((0.1, 0.7, 0.9)) c = group.colors c.active, c.normal, c.select = black, black, select return group link.bone_group = bgroup('<>') Set.mode(context, mode, rig) # if active: # Set.active(context, active) return {'FINISHED'}