-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_animation.py
48 lines (44 loc) · 1.6 KB
/
remove_animation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""
@FileName : remove_animation.py
@DateTime : 2023/08/11 14:35:20
@Author : Tian Chao
@Contact : [email protected]
@Software : Maya 2023.3
@PythonVersion : python 3.9.7
"""
import pymel.core as pm
def deleteConnection(plug):
"""
Deletes the connection of the given plug.
Parameters:
plug (str): The plug to delete the connection for.
Returns:
None
"""
# 如果接口是连接的目标,则返回 true,否则返回 false。参数isDestination:是连接目标
if pm.connectionInfo(plug, isDestination=True):
# 获取确切目标接口,如果没有这样的连接,则返回None。
plug = pm.connectionInfo(plug, getExactDestination=True)
readOnly = pm.ls(plug, readOnly=True)
# 如果该属性为只读
if readOnly:
# 获取连接的源接口
source = pm.connectionInfo(plug, sourceFromDestination=True)
# 断开源接口和目标接口
pm.disconnectAttr(source, plug)
else:
# 如果不为只读,则删除目标接口
# inputConnectionsAndNodes: 如果目标接口为只读,则不会删除
pm.delete(plug, inputConnectionsAndNodes=True)
if __name__ == "__main__":
# 获取选择列表
sel_list = pm.selected()
# 遍历选择列表
for obj in sel_list:
# 列出可动画属性
attrs = obj.listAnimatable()
# 遍历可动画属性
for attr in attrs:
# 断开动画连接
deleteConnection(f"{attr}")