pythonmayamaya-api

Connecting array attributes in Maya Python API 2.0


How to connect 2 array attributes using Maya Python API 2.0? e.g:

joint1.worldMatrix[0] >> skinCluster1.matrix[0]

I can find plugs but how to connect them?

import maya.api.OpenMaya as om

node = 'skinCluster1'
attr = 'matrix'
index = 0
def get_plug(node=None, attr=None,index=0):
    m_selection_list = om.MSelectionList()
    m_selection_list.add(node)
    dependency_node_object =       m_selection_list.getDependNode(0)
    dp_node = om.MFnDependencyNode(dependency_node_object)
    attr_plug = dp_node.findPlug(attr, 0)

Solution

  • Answering my own question :

    om.MPlug.elementByLogicalIndex(index)
    

    this will return plug with indexed attribute.

    MDGMoifier() do have connect function. One should pass source and destination plugs and then use doIi() function to connect. I think this answers the question.