Skip to content

Commit

Permalink
pymaya.cmds fix listConnections implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcampos committed Oct 30, 2024
1 parent 75cfe41 commit 86f78f1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion release/scripts/mgear/pymaya/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from maya.api import OpenMaya
import functools
import inspect
import pprint


__all__ = []
Expand Down Expand Up @@ -350,16 +351,30 @@ def listConnections(*args, sourceFirst=False, **kwargs):
kwargs = _obj_to_name(kwargs)

if sourceFirst:
# first list the source connections
if 'source' not in kwargs or not kwargs['source']:
kwargs['source'] = True
if 'destination' not in kwargs or kwargs['destination']:
kwargs['destination'] = False

connections = cmds.listConnections(*args, **kwargs) or []
res = [
res_source = [
(connections[i + 1], connections[i])
for i in range(0, len(connections), 2)
]

# add the connections from the destination side
kwargs['source'] = False
kwargs['destination'] = True

connections = cmds.listConnections(*args, **kwargs) or []
res_destination = [
(connections[i], connections[i + 1])
for i in range(0, len(connections), 2)
]

res = res_destination + res_source

else:
res = cmds.listConnections(*args, **kwargs) or []
return _name_to_obj(res)
Expand Down

0 comments on commit 86f78f1

Please sign in to comment.