MetaFusion/scripts/bsIndex.py
2025-01-15 23:58:58 +08:00

38 lines
1.4 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pymel.core as pm
import maya.cmds as cmds
import sys
def calc():
selected_meshes = cmds.ls(sl=True)
targetblend = selected_meshes[0]
# 假设'rl4Embedded_Archtype'是节点的名称
node_name = 'head_lod0_mesh_blendShapes'
# 获取指定节点的PyNode
node = pm.PyNode(node_name)
# 假设'bs_Output'是输出属性的名称
output_attr = node.weight
# 获取输出属性的连接插件
connected_plugs = output_attr.connections(plugs=True)
blendIndex = []
# 遍历连接的插件并打印它们的值
for index, plug in enumerate(connected_plugs, start=1):
sub_node_value = plug.get()
if sub_node_value == 1:
print("Sub-node {} value: {}".format(index-1, sub_node_value))
blendIndex = index-1
print (blendIndex)
blend_shape_node = 'head_lod0_mesh_blendShapes'
rebuild_mesh = cmds.sculptTarget(blend_shape_node, e=True, regenerate=True, target=blendIndex)
cmds.select(rebuild_mesh)
blend_shape_node = "blendShape1"
cmds.blendShape(rebuild_mesh[0], automatic=True)
cmds.blendShape(blend_shape_node, edit=True, target=(rebuild_mesh[0], 2, targetblend+"_corrective", 1.0))
cmds.setAttr(blend_shape_node+"."+targetblend+"_corrective", 1)
#cmds.delete(rebuild_mesh[0])
cmds.delete(targetblend+"_corrective")