Hey Everyone,

Finally diving back into the world of the python api and i'm pulling
my hair out trying to get the intersection point on a nurbs surface.
I'm trying this on a scene with a nurbs plane at 0 0 3 and a
raystartingpoint of 0, 0, 0.

In this code, raystartingpoint is 0 0 0 1, and alongthisdirection is
hardwired to 0 0 1 down z. Maya will crash If I have the
calculateExactHit set to True. Otherwise, it's not giving results I
trust.

My first question is what the heck is kMfnNurbsEpsilon and how to I
address it from python. The only reference I've found is in this call
and the nurbs curve and both are args. All c++ examples I've found
call it directly by name. I've set this to 1, but this is a total
guess and could be the cause of my issues.

BONUS QUESTION: Additionally, assuming I can get this to work. I'm
expecting the 3rd vertical column of the .xformMatrix of a locator
would be the 'alongthisdirection' arg expected from MFnNurbsSurface,
is this a correct assumption. If not how does one get the direction of
a object.

Can someone shed some light on what's up here? Thanks a ton!!!!
Doug

Here's my test code:

def getIntersection():

    slist = om.MSelectionList()
    om.MGlobal.getSelectionListByName('nurbsPlaneShape1', slist)

    nurbsObj = om.MObject()
    nurbsDag = om.MDagPath()

    slist.getDependNode(0, nurbsObj)
    slist.getDagPath(0, nurbsDag, nurbsObj)
    fnSurface = om.MFnNurbsSurface(nurbsDag)

    spc = om.MSpace.kWorld

    #locatorXformMatrix = mc.getAttr("locator2" + ".xformMatrix")
    #direction = om.MVector(locatorXformMatrix[2], locatorXformMatrix
[6], locatorXformMatrix[10])

    startPoint = om.MPoint(0.0, 0.0, 0.0, 1)
    direction = om.MVector(0, 0, 1)

    uSU = om.MScriptUtil()
    vSU = om.MScriptUtil()
    uPtr = uSU.asDoublePtr()
    vPtr = uSU.asDoublePtr()

    interPoint = om.MPoint()

    toleranceSU = om.MScriptUtil()
    tolerance = toleranceSU.asDoublePtr()
    om.MScriptUtil.setDouble(tolerance, .1)

    value = fnSurface.intersect(startPoint, direction, uPtr, vPtr,
interPoint, toleranceSU.asDouble(), spc, False, None, False, None)

    print value
    print interPoint.x, interPoint.y, interPoint.z
    return (interPoint.x, interPoint.y, interPoint.z)



-- 
http://groups.google.com/group/python_inside_maya

Reply via email to