def clearShaderConnections(ts="", geo="", *args):
myShape = cmds.listRelatives(geo, s=True)[0]
tsList = cmds.listAttr(ts, m=True, st=["*input*"])
if tsList:
# delete empty entries? ?
# for tsInput in tsList:
# shpList = cmds.connectionInfo("{0}.{1}.inShape".format(ts, tsInput), sfd=True)
# if not shpList:
# cmds.removeMultiInstance("blinn1_TripleSwitch.{0}".format(tsInput))
for tsInput in tsList:
shpList = cmds.connectionInfo("{0}.{1}.inShape".format(ts, tsInput), sfd=True).partition(".")
shp = ""
if shpList:
shp = shpList[0]
if shp == myShape:
# clear out the shape node
cmds.disconnectAttr("{0}.instObjGroups[0]".format(shp), "{0}.{1}.inShape".format(ts, tsInput))
# clear out the texture (delete if we can)
txt = cmds.connectionInfo("{0}.{1}.inTriple".format(ts, tsInput), sfd=True).partition(".")[0]
cmds.disconnectAttr("{0}.outColor".format(txt), "{0}.{1}.inTriple".format(ts, tsInput))
p2d = cmds.connectionInfo("{0}.uvCoord".format(txt), sfd=True).partition(".")[0]
cmds.delete(txt, p2d)
评论列表
文章目录