sel.getDagPath(0,dag) meaning....

903 views
Skip to first unread message

e955...@gmail.com

unread,
Oct 13, 2014, 2:32:28 PM10/13/14
to python_in...@googlegroups.com
hello everyoneee

i have a script which works fine when i run it in the script editor, but when i add it to part of my larger script and run it, it has this error:

formLayout.py line 215: getDagPath() takes exactly one argument (2 given)

this is line 215: sel.getDagPath(0,dag)

Im still not very clear on dag paths and looking online im getting a little confused. can someone explain to me in simple terms what this line does and maybe why it takes one argument?. because it seems to accept the "0,dag" when i run the script seperately.

thanks in advance,
Sam

Justin Israel

unread,
Oct 13, 2014, 2:43:55 PM10/13/14
to python_in...@googlegroups.com

Which class are you dealing with when you call getDagPath?
The docs explain the usage:

http://download.autodesk.com/us/maya/2010help/API/class_m_selection_list.html#e2c80bef6a4c0c23fdba1bba25bc31c5

http://download.autodesk.com/us/maya/2011help/API/class_m_it_selection_list.html#47eaf93b417b90d4f0d81754e7ef983f

For MSelectionList the int is the index into the list, and the second argument is where the result should be stored.

Can you show an example of the code you are running for context?

--
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/862b07ff-7c99-4401-a7cc-197bb86899f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

e955...@gmail.com

unread,
Oct 13, 2014, 3:29:18 PM10/13/14
to python_in...@googlegroups.com
thanks Justin,

here is an example of the code i have:

def returnCollisionPoints(point=(point), dir=(-newX,-newY, -newZ)):
sel = om.MSelectionList()
dag = om.MDagPath()

sel.add("pSphereShape1")
sel.getDagPath(0,dag)

mesh = om.MFnMesh(dag)

point = om.MFloatPoint(*point)
dir = om.MFloatVector(*dir)
hitPoints = om.MFloatPointArray()

mesh.allIntersections(
point, dir,
None, None,
False, om.MSpace.kWorld,
10000, False,
None,
None,
hitPoints,
None, None,
None, None,
None
)
return hitPoints

i will read up on those docs, thanks for helping. Im not even sure why the mesh.allIntersections needs to be written like that or if theres a cleaner way

33th...@gmail.com

unread,
Oct 13, 2014, 5:49:12 PM10/13/14
to python_in...@googlegroups.com
Which api are you importing?

e955...@gmail.com

unread,
Oct 13, 2014, 7:13:37 PM10/13/14
to python_in...@googlegroups.com, 33th...@gmail.com
not sure what that means. this?

import maya.cmds as cmds
import sys, math
import maya.api.OpenMaya as om

Sam

kevco...@gmail.com

unread,
Oct 13, 2014, 8:49:04 PM10/13/14
to python_in...@googlegroups.com, 33th...@gmail.com, e955...@gmail.com
You seem to be importing the python version 2.0 api, but are using methods as if they're from version 1.0

for 2.0, it would be

dag = sel.getDagPath(0)

for version 1.0, you would write it like you have it, but you need to be importing maya.OpenMaya not maya.api.OpenMaya

hope that helps.

e955...@gmail.com

unread,
Oct 14, 2014, 4:23:35 AM10/14/14
to python_in...@googlegroups.com, 33th...@gmail.com, e955...@gmail.com, kevco...@gmail.com
ah, that explains alot ha. thanks!. Do you think its better to use the 2.0 api?
Reply all
Reply to author
Forward
0 new messages