Node path connected to output Plug

76 views
Skip to first unread message

Janos Hunyadi

unread,
May 22, 2015, 8:40:57 AM5/22/15
to python_in...@googlegroups.com


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

Justin Israel

unread,
May 22, 2015, 5:49:22 PM5/22/15
to python_in...@googlegroups.com
Are you trying to determine the dagpath of all objects connected to the worldMesh[0] output plug?

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/85465a8e-2517-4fff-b891-24438d8c9522%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Janos Hunyadi

unread,
May 23, 2015, 3:21:17 AM5/23/15
to python_in...@googlegroups.com
Basically yes. I only need the first connected (logical index) one.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
May 24, 2015, 12:39:17 AM5/24/15
to python_in...@googlegroups.com

Does this work for you?

# Via the API

import 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 cmds
import maya.cmds as cmds
cmds.ls(cmds.listConnections("pPlaneShape1.worldMesh[0]", sh=True), l=True)

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9a734e78-fadd-42fa-888c-b52be36929c4%40googlegroups.com.

Janos Hunyadi

unread,
May 24, 2015, 5:10:33 AM5/24/15
to python_in...@googlegroups.com
Works flawlessly! Thank you! :)
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
May 24, 2015, 5:51:28 AM5/24/15
to python_in...@googlegroups.com

Welcome!


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/40969e04-455c-4bf4-a2c7-82c1e6862c31%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages