Does this work for you?

# Via the APIimport maya.OpenMaya as api

sel = api.MSelectionList()
sel.add( 'pPlaneShape1' )
obj = api.MDagPath()
sel.getDagPath(0, obj )

dgNode = api.MFnDagNode(obj)
aliasList = dgNode.findPlug( "worldMesh" )
worldP = aliasList[0]print worldP.name()

mfDgN = api.MFnDagNode(worldP.node())print mfDgN.fullPathName()

destPlugs = api.MPlugArray()
worldP.connectedTo(destPlugs, False, True)
destPlug = destPlugs[0]
mfDgN.setObject(destPlug.node())print mfDgN.fullPathName()
# Via cmdsimport maya.cmds as
cmdscmds.ls(cmds.listConnections("pPlaneShape1.worldMesh[0]",
sh=True), l=True)

​

On Sat, May 23, 2015 at 7:21 PM Janos Hunyadi <[email protected]> wrote:

> Basically yes. I only need the first connected (logical index) one.
>
>
> On Friday, May 22, 2015 at 11:49:22 PM UTC+2, Justin Israel wrote:
>
>> Are you trying to determine the dagpath of all objects connected to the
>> worldMesh[0] output plug?
>>
>> On Sat, May 23, 2015 at 12:41 AM Janos Hunyadi <[email protected]> wrote:
>>
>>>
>>>
>>> Hi guys!
>>>
>>> I'm trying to find a simple way to find a nodes *DagPath *connected
>>> from a mesh* ("worldMesh[0]") output plug.*
>>>
>>> This is a command so it won't be inside a compute.
>>>
>>> Here's some python prototype code (*not working*):
>>>
>>> import maya.OpenMaya as api
>>> sel = api.MSelectionList()
>>> sel.add( 'pPlaneShape1' )
>>> obj = api.MDagPath()
>>> sel.getDagPath(0, obj )
>>>
>>>
>>> dgNode = api.MFnDagNode(obj)
>>>
>>> aliasList = api.MPlug()
>>> aliasList = dgNode.findPlug( "worldMesh" )
>>>
>>> worldP = api.MPlug()
>>> worldP = aliasList[0]
>>>
>>> # The plug is found!
>>> print worldP.name()
>>>
>>>
>>> # Ok lets convert it to a dagpath!
>>> ob = api.MObject()
>>> ob = worldP.asMObject()
>>>
>>> mfDgN = api.MFnDagNode(worldP.node())
>>>
>>> pa = api.MDagPath()
>>>
>>> mfDgN.getPath(pa)
>>> print pa.fullPathName()
>>>
>>> # Nope!
>>>
>>>
>>> Any ideas? :D
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/85465a8e-2517-4fff-b891-24438d8c9522%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/85465a8e-2517-4fff-b891-24438d8c9522%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/9a734e78-fadd-42fa-888c-b52be36929c4%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/9a734e78-fadd-42fa-888c-b52be36929c4%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0nFWCThfgz3HHZz7T2gDHVjiG_uLJnY1iSBQRcz5UdPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to