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
Which class are you dealing with when you call getDagPath?
The docs explain the usage:
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.
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
import maya.cmds as cmds
import sys, math
import maya.api.OpenMaya as om
Sam
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.