import maya.OpenMaya as om
# this creates the float2
pArray = [0,0]
x1 = om.MScriptUtil()
x1.createFromList( pArray, 2 )
uvPoint = x1.asFloat2Ptr()
# (call to OpenMaya.MFnMesh.getUVAtPoint( ..., uvPoint, ... )
# goes here)
# retrieve results
uv0 = om.MScriptUtil.getFloat2ArrayItem( uvPoint, 0, 0 )
uv1 = om.MScriptUtil.getFloat2ArrayItem( uvPoint, 0, 1 )
Curiously enough the '2' in float2ptr and float2array refers to 2-dimensional arrays, hence the extra 0 in the call to the latter. We're only dealing with float2& (which typedefs to float[2]) in our getUVAtPoint call, but frankly: did you expect anything else than a hackfest when you popped that Maya 2009 box open?
I don't know how you worked that out but you really saved my bacon - I would never have got this without you! I can't believe you have to use a two dimensional array to access a one dimensional array...
ReplyDeleteMan, thanks so much, this may be an old post but it saved hours of frustration!
ReplyDelete:p
Thank you so much for posting this. It was exactly this function I was having problems with, and the float2 oddness.
ReplyDelete