Accessing other attributes on node during connectionMade

23 views
Skip to first unread message

Bay

unread,
Jan 27, 2015, 2:05:06 AM1/27/15
to python_in...@googlegroups.com
Hi guys, 
            appreciate it if anyone could spare the time to answer my question.  My node design is like so 

========NODE=============
Array[0]:
Input:

Mtx:

Array[1]:
Input:

Mtx:

It's very simplified of course. My question is that I would like it when I make a connection into the input, I am able to access the mtx attribute to query and set Value on it via the connectionMade function. Since unlike the compute I don't have access to the datablock and can only rely on the plug/ otherplug variable I was wondering how would I be able to get the mtx attribute via the MPlug commands ? I couldn't use a direct connection as it would result in a cycle so any assistance would be much appreciated : )

Thank you
Gann Boon Bay 

Bay

unread,
Jan 28, 2015, 2:48:46 PM1/28/15
to python_in...@googlegroups.com

Hi,  
    managed to solve it. My solution code is to grab the dependency node that the plug belongs to and use the MFnDependency functions to find the plug with the attribute name that I want. Since worldmatrix (At least in my situation) will always be the first element of the array, I just grab the first element and store the value as a MObject to access its information. 

            node = otherplug.node()
            dependency_object = api.MFnDependencyNode(node)
            world_matrix_plug = dependency_object.findPlug('worldMatrix')
            result = world_matrix_plug.elementByLogicalIndex(0)
            input_mobject = result.asMObject()


Reply all
Reply to author
Forward
0 new messages