Changeset View
Changeset View
Standalone View
Standalone View
rigify/generate.py
| Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if id_store.rigify_generate_mode == 'overwrite': | ||||
| try: | try: | ||||
| obj = scene.objects[name] | obj = scene.objects[name] | ||||
| rig_old_name = name | rig_old_name = name | ||||
| obj.name = rig_new_name or name | obj.name = rig_new_name or name | ||||
| except KeyError: | except KeyError: | ||||
| rig_old_name = name | rig_old_name = name | ||||
| name = rig_new_name or name | name = rig_new_name or name | ||||
| obj = bpy.data.objects.new(name, bpy.data.armatures.new(name)) | obj = bpy.data.objects.new(name, bpy.data.armatures.new(name)) | ||||
| obj.draw_type = 'WIRE' | obj.display_type = 'WIRE' | ||||
| scene.objects.link(obj) | scene.objects.link(obj) | ||||
| else: | else: | ||||
| name = rig_new_name or "rig" | name = rig_new_name or "rig" | ||||
| obj = bpy.data.objects.new(name, bpy.data.armatures.new(name)) # in case name 'rig' exists it will be rig.001 | obj = bpy.data.objects.new(name, bpy.data.armatures.new(name)) # in case name 'rig' exists it will be rig.001 | ||||
| obj.draw_type = 'WIRE' | obj.display_type = 'WIRE' | ||||
| scene.objects.link(obj) | scene.objects.link(obj) | ||||
| id_store.rigify_target_rig = obj.name | id_store.rigify_target_rig = obj.name | ||||
| obj.data.pose_position = 'POSE' | obj.data.pose_position = 'POSE' | ||||
| # Get rid of anim data in case the rig already existed | # Get rid of anim data in case the rig already existed | ||||
| print("Clear rig animation data.") | print("Clear rig animation data.") | ||||
| obj.animation_data_clear() | obj.animation_data_clear() | ||||
| ▲ Show 20 Lines • Show All 435 Lines • ▼ Show 20 Lines | def create_selection_sets(obj, metarig): | ||||
| bpy.ops.object.mode_set(mode='POSE') | bpy.ops.object.mode_set(mode='POSE') | ||||
| bpy.context.scene.objects.active = obj | bpy.context.scene.objects.active = obj | ||||
| obj.select = True | obj.select = True | ||||
| metarig.select = False | metarig.select = False | ||||
| pbones = obj.pose.bones | pbones = obj.pose.bones | ||||
| for i, name in enumerate(metarig.data.rigify_layers.keys()): | for i, name in enumerate(metarig.data.rigify_layers.keys()): | ||||
| if name == '' or not metarig.data.rigify_layers[i].set: | if name == '' or not metarig.data.rigify_layers[i].selset: | ||||
| continue | continue | ||||
| bpy.ops.pose.select_all(action='DESELECT') | bpy.ops.pose.select_all(action='DESELECT') | ||||
| for b in pbones: | for b in pbones: | ||||
| if b.bone.layers[i]: | if b.bone.layers[i]: | ||||
| b.bone.select = True | b.bone.select = True | ||||
| #bpy.ops.pose.selection_set_add() | #bpy.ops.pose.selection_set_add() | ||||
| ▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines | |||||