This commit is contained in:
2025-11-24 21:05:22 +08:00
parent e76152945e
commit e4c713035b
12 changed files with 585 additions and 414 deletions

View File

@@ -4,15 +4,10 @@
"""
Skin API UI Functions
提供权重导出、导入和解绑的用户界面函数
支持 Maya 所有版本,兼容 pymel 和 cmds
"""
# 确保 Maya 环境已初始化
try:
import maya.standalone
maya.standalone.initialize()
except:
pass
# 尝试导入 pymel如果不可用则使用 cmds
try:
import pymel.core as pm
except ImportError:
@@ -29,7 +24,6 @@ except ImportError:
def WeightExport():
"""
导出选中物体的蒙皮权重
Export skin weights for selected objects
"""
try:
@@ -37,12 +31,12 @@ def WeightExport():
if pm:
selectedNodes = pm.ls(sl=True)
if not selectedNodes:
pm.warning("请选择至少一个蒙皮物体 / Please select at least one skinned object")
pm.warning("Please select at least one skinned object")
return
else:
selectedNodes = cmds.ls(sl=True)
if not selectedNodes:
cmds.warning("请选择至少一个蒙皮物体 / Please select at least one skinned object")
cmds.warning("Please select at least one skinned object")
return
# 使用 ApiVtxAttribs 类导出权重
@@ -76,7 +70,6 @@ def WeightExport():
def WeightImport():
"""
导入蒙皮权重到选中物体或场景中匹配的物体
Import skin weights to selected or matching objects in scene
"""
try:
@@ -155,19 +148,19 @@ def UnbindSkin():
if pm:
selectedNodes = pm.ls(sl=True)
if not selectedNodes:
pm.warning("请选择至少一个物体 / Please select at least one object")
pm.warning("Please select at least one object")
return
else:
selectedNodes = cmds.ls(sl=True)
if not selectedNodes:
cmds.warning("请选择至少一个物体 / Please select at least one object")
cmds.warning("Please select at least one object")
return
# 确认对话框
if pm:
result = pm.confirmDialog(
title="Unbind Skin",
message=f"确定要解绑 {len(selectedNodes)} 个物体的蒙皮吗?\nAre you sure you want to unbind skin from {len(selectedNodes)} object(s)?",
message=f"Are you sure you want to unbind skin from {len(selectedNodes)} object(s)?",
button=["Yes", "No"],
defaultButton="Yes",
cancelButton="No",
@@ -176,7 +169,7 @@ def UnbindSkin():
else:
result = cmds.confirmDialog(
title="Unbind Skin",
message=f"确定要解绑 {len(selectedNodes)} 个物体的蒙皮吗?\nAre you sure you want to unbind skin from {len(selectedNodes)} object(s)?",
message=f"Are you sure you want to unbind skin from {len(selectedNodes)} object(s)?",
button=["Yes", "No"],
defaultButton="Yes",
cancelButton="No",
@@ -189,7 +182,7 @@ def UnbindSkin():
# 使用 MEL 命令解绑蒙皮
mel.eval('doDetachSkin "2" { "1","1" };')
print("已取消蒙皮!/ Skin unbound!")
print("Skin unbound successfully!")
if pm:
pm.confirmDialog(