wdavidlewis
09-11-2009, 06:41 PM
I'm trying to write my first context plugin and I decided to try Python rather than C++.
In the doPress() method, I'm getting the screen coordinates of the mouse click and then calling viewToWorld(). When I do so, Maya hard crashes (i.e. it just goes away). Here's the code: argX = OpenMaya.MScriptUtil()
argX.createFromInt(0)
argXPtr = argX.asShortPtr()
argY = OpenMaya.MScriptUtil()
argY.createFromInt(0)
argYPtr = argY.asShortPtr()
event.getPosition(argXPtr, argYPtr)
sx = OpenMaya.MScriptUtil(argXPtr).asShort()
sy = OpenMaya.MScriptUtil(argYPtr).asShort()
print "pos = (" + str(sx) + ", " + str(sy) + ")\n"
originPt = OpenMaya.MPoint()
vec = OpenMaya.MVector()
nearClip = OpenMaya.MPoint()
farClip = OpenMaya.MPoint()
OpenMayaUI.M3dView().viewToWorld(sx, sy, nearClip, farClip)
Nothing tricky here. If I comment out viewToWorld() call, no crash.
I've tried both the nearClip/farClip version and the point/vector version. Both just crash. The screen coords I'm getting are correct. Though I have also tried just passing in (50, 50) and that crashes too.
Any ideas?
Thanks!
--- David
In the doPress() method, I'm getting the screen coordinates of the mouse click and then calling viewToWorld(). When I do so, Maya hard crashes (i.e. it just goes away). Here's the code: argX = OpenMaya.MScriptUtil()
argX.createFromInt(0)
argXPtr = argX.asShortPtr()
argY = OpenMaya.MScriptUtil()
argY.createFromInt(0)
argYPtr = argY.asShortPtr()
event.getPosition(argXPtr, argYPtr)
sx = OpenMaya.MScriptUtil(argXPtr).asShort()
sy = OpenMaya.MScriptUtil(argYPtr).asShort()
print "pos = (" + str(sx) + ", " + str(sy) + ")\n"
originPt = OpenMaya.MPoint()
vec = OpenMaya.MVector()
nearClip = OpenMaya.MPoint()
farClip = OpenMaya.MPoint()
OpenMayaUI.M3dView().viewToWorld(sx, sy, nearClip, farClip)
Nothing tricky here. If I comment out viewToWorld() call, no crash.
I've tried both the nearClip/farClip version and the point/vector version. Both just crash. The screen coords I'm getting are correct. Though I have also tried just passing in (50, 50) and that crashes too.
Any ideas?
Thanks!
--- David
