#!/usr/bin/env python # -*- coding: utf-8 -*- import maya.cmds as cmds import maya.mel as mel from Core import GetJoints, SetColor def create_rl4_node(dna, name): """ 创建RL4节点 参数: dna (str): DNA文件路径 name (str): 节点名称 """ # 删除现有的RL4节点 mel.eval('SGDeleteRL4Node') # 重置所有关节的颜色 joints = GetJoints() for joint in joints: SetColor(joint, 0, 0, 0, 0, 0, 0) # 查找有效的LOD级别 lod = None for i in range(8): joint_lod = GetJoints(lod=i, type="string") exists = True # 检查所有关节是否存在 for joint in joint_lod: if not cmds.objExists(joint): exists = False break if exists: lod = i break # 修复LOD 0的关节 mel.eval('SGRepairJointForLOD 0') # 设置命名空间和属性路径 if cmds.namespace(exists="DHIhead"): joint_name = "DHIhead:." else: joint_name = "." # 设置各种命名模式 anim_multiplier_name = "FRM_WMmultipliers._" blend_shape_name = "_blendShapes." control_name = "." # 创建嵌入式RL4节点 cmds.createEmbeddedNodeRL4( dfp=dna, # DNA文件路径 amn=anim_multiplier_name, # 动画乘数名称 bsn=blend_shape_name, # 混合变形名称 cn=control_name, # 控制器名称 jn=joint_name, # 关节名称 n=name # 节点名称 ) # 删除指定LOD级别的关节 mel.eval(f'SGDeleteJointForLOD {lod}')