-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremoveRefedits.py
31 lines (23 loc) · 1.07 KB
/
removeRefedits.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
import lib.libmaya as libmaya
def getEdits(refNode):
editCommands = ['disconnectAttr', 'setAttr', 'connectAttr']
refEdits = {i: [] for i in editCommands}
for key, val in refEdits.iteritems():
val[:] = list(set(cmds.referenceQuery(refNode, editStrings=True, editCommand=key, showDagPath=False)))
return refEdits
references = libmaya.getReferences(True)
ref = references['Yourref']
ref['editsRef'] = getEdits(ref['refNode'])
['wl[', 'weightList[', 'lodVisibility', 'overrideEnabled', 'output']
pattern = 'wl['
for editType, edits in ref['editsRef'].iteritems():
finalList = []
for i in edits:
if pattern in i:
toDel = i.split(' ')[1]
finalList.append('Yourref:' + toDel.split('.')[0])
cmds.referenceEdit('Yourref:' + toDel, failedEdits=True, successfulEdits=True, editCommand=editType, removeEdits=True) # For the attribute
# For the node
finalList = list(set(finalList))
for i in finalList:
cmds.referenceEdit(i, failedEdits=True, successfulEdits=True, editCommand=editType, removeEdits=True)