Skip to content

Commit

Permalink
added extract_blend_shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvaes authored Feb 4, 2023
1 parent a515c51 commit 12d9c02
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion blend_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ def turn_off_all_blend_shapes(blend_shape_node):

return all_weights

def extract_blend_shapes(blend_shape_node):
"""
Extract the blend shape targets as separate meshes in the scene
:param blend_shape_node:
:return: *list* of newly generated meshes
"""
generated = []
mesh = get_mesh_from_blend_shape_node(blend_shape_node)
for target_name in get_blend_shape_target_names(blend_shape_node):
set_blend_shape_value(blend_shape_node, target_name, 1)
dupe = pm.duplicate(mesh, name=target_name)
generated.append(pm.PyNode(dupe))

return generated

def get_mesh_from_blend_shape_node(blend_shape_node):
"""
Get the mesh the blend shape node is attached to
:param blend_shape_node:
:return:
"""
return pm.listHistory(blend_shape_node, type="shape")[0].getParent()

def get_blend_shape_target_names(blend_shape_node):
"""
Expand All @@ -61,7 +83,6 @@ def get_blend_shape_target_names(blend_shape_node):
blend_shape_node = pm.PyNode(blend_shape_node)
return [weight.getAlias() for weight in blend_shape_node.w]


def transfer_blend_shapes(source, target, specific_blend_shape_nodes=None):
"""
Transfers the blend shapes from one mesh to another.
Expand Down

0 comments on commit 12d9c02

Please sign in to comment.