Incoming connections finding for attribute


How to find out if there is any incoming connection or not for attribute (eg :- translateX),

if there is connection to (translate X).
result = 1.

if there is no connection to (translate X).
result = 0.

anybody plzzz help me…


There’s a command called “listConnections” to deal with this.

import maya.cmds as cmds

if cmds.listConnections("someNode.tx",d=0):

#Or on a single line:
result= 1 if cmds.listConnections("someNode.tx",d=0,s=1) else 0

Generally, if you want to figure out what commands to use, it’s good to peruse the docs, as well as some scripts that others have released. You’ll be able to figure out yourself what kinds of commands you can use and how (unless it’s something obscure).


Or with pymel:

someNode = pm.PyNode("youNode")
len(someNode.translateX.inputs()) > 0


Thanks Guys for giving reply i want the code in mel…


What about trying to search for “listConnections” in the maya help? Could help.


listConnections was not helpful i want code in mel not in python plzzzz send me…


I don’t mean to be a dick, but did you actually take a look at the docs? Did you try anything?
What do you mean “listConnections was not helpful”?

I’m all for helping, no doubt. Though it seems like you just want others to write your tool for you.

Besides, as for this question with listConnections in MEL, you’ve pretty much answered it yourself with your code example in your other thread:


I believe AaronStone was asking for incoming connection to specific attributes and was confused with cmds being a mel wrapper for python

if(`listConnections “myobj.tx” -d 0`):
result = 1;

would do in mel just fine.