I’m new to python and after a lot of time trying to solve a problem, I’m pretty lost so I thought I’d ask my first question here.
I have a main file with a referenced file in Maya, where I am trying to list the connections of a certain node, for which the source is in the referenced file and the destination is in the main file
import pymel.core # get relevant list: aSourceNodeCC = cmds.ls ("ShaderReference:CC*") # source details for eSourceNodeCC in aSourceNodeCC: # destination details if cmds.connectionInfo ('%s.outColor' % eSourceNodeCC, destinationFromSource = 1) is not None: aConnectionCC = cmds.connectionInfo ('%s.outColor' % eSourceNodeCC, destinationFromSource = 1) # list generation for eConnectionCC in aConnectionCC: aConnectionCCMaster = eSourceNodeCC + ('.outColor ') + eConnectionCC print aConnectionCCMaster
The issues I’m having is that the CC* nodes sometimes have connections within the referenced file as well as the main file. I only need the connections to the main file, and am struggling to filter out the ones that are connected to other nodes within the referenced file. i.e. I need to keep entries that look like:
but need to exclude entries that look like:
Any help would be very much appreciated. Thanks.
# list generation for eConnectionCC in aConnectionCC: # check if ref if cmds.referenceQuery(eConnectionCC, isNodeReferenced=True): continue aConnectionCCMaster = eSourceNodeCC + ('.outColor ') + eConnectionCC print aConnectionCCMaster