1

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)

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This does answer the question how to find an attribute in an array attribute, but it does not answer the question how to connect them.
Sorry I edited my post. MDGMoifier() does this function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.