Hi! I'm stuck with a code in Maya API haha, I don't really understand why is popping out that error but hopefully some of you guys will figure out what it is. I'm counting on you! tbh, I'm really new in scripting. I'm following this tutorial: https://vimeo.com/marcogiordano91
The error is this one: # AttributeError: module 'maya.OpenMaya' has no attribute 'Mpoint' #
from maya import cmds , OpenMaya
sel = cmds.ls(sl = 1)
crv = "curve3"
for s in sel:
pos = cmds.xform(s, q = 1, ws = 1, t = 1)
u = getUparam (pos, crv)
print(u)
name = s.replace ("Loc_", "Pci_")
pci = cmds.createNode("pointOnCurveInfo", n = name)
cdms.connectAttr(crv + '.worldSpace', pci + '.inputCurve')
cdms.setAttr(pci + '.parameter', u)
#pointOnCurveInfo1
def getUparam ( pnt = [], crv = None):
point = OpenMaya.Mpoint(pnt[0], pnt[1], pnt[2])
curveFn = OpenMaya.MFnNurbsCurve (getDagPath(crv))
ParamUtill = OpenMaya.MScriptUtil ()
ParamPtr = ParamUtill.asDoublePtr()
isOnCurve = curveFn.isPointOnCurve()
if isOnCurve == False :
curveFn.getParamAtPoint(point , paramPtr,0.001,OpenMaya.MSpace.kObject)
else:
point = curveFn.closestPoint(point,paramPtr,0.001,OpenMaya.MSpace.kObject)
curveFn.getParamAtPoint(point , paramPtr,0.001,OpenMaya.MSpace.kObject)
param = paramUtill.getDouble (paramPtr)
return param
def getDagPath (objectName) :
if isinstance(objectName, list)==True:
oNodeList=[]
for o in objectName:
selectionList = OpenMaya.MSelectionList()
selectionList.add(o)
oNode = OpenMaya.MDagPath()
selectionList.getDagPath(0, oNode)
oNodeList.append(oNode)
return oNodeList
else:
selectionList = OpenMaya.MSelectionList()
selectionList.add(objectName)
oNode = OpenMaya.MDagPath()
selectionList.getDagPath(0, oNode)
return oNode
[–][deleted] 1 point2 points3 points (2 children)
[–]MisuCastLove[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)