Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I couldn't find a direct way to make a connection to a multi-attribute in Python when I don't know if there are connections already. I am trying to connect to a Set node's "usedBy" attribute, but it looks like its indexMatters flag is not set to false, so using "connectAttr" with "nextAvailable=True" fails.
I ended up using MEL's "getNextFreeMultiIndex" to find the next available index as shown below, but going to MEL within a Python script feels awkward and I was wondering if there was a more direct way to do it.
Here is how I am handling it now:
import maya.cmds as cmds import maya.mel as mel idx = mel.eval('getNextFreeMultiIndex "' + theSet + '.usedBy" 0') cmds.connectAttr(myNode + '.message', theSet + '.usedBy[' + str(idx) + ']')
Did I miss a Python command that can handle this?
Thanks!
Solved! Go to Solution.