Maya Selected Node All Childs node disconnectAttr Loop

選択したノード以下のすべての接続を解除するループ

import maya.cmds as cmds
selectionNode=cmds.ls(sl=True)
# 指定したノード以下全てを検索
selectionNodes=cmds.ls(selectionNode,dag=1)
for node in selectionNodes:
	try:
		attribute1 =node+"_translateX.output"
		attribute2 =node+".translateX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass
	

	try:
		attribute1 =node+"_translateY.output"
		attribute2 =node+".translateY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_translateZ.output"
		attribute2 =node+".translateZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateX.output"
		attribute2 =node+".rotateX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateY.output"
		attribute2 =node+".rotateY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_rotateZ.output"
		attribute2 =node+".rotateZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleX.output"
		attribute2 =node+".scaleX"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleY.output"
		attribute2 =node+".scaleY"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

	try:
		attribute1 =node+"_scaleZ.output"
		attribute2 =node+".scaleZ"
		cmds.disconnectAttr(attribute1, attribute2)
	except RuntimeError as err:
		pass

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です