The following script gets you the world position from a random uv-coordinate of
the selected object.
I affraid I don't know what you mean with symmetry line.
import maya.OpenMaya as om
import maya.cmds as cmds
import random
def GetDagPath(nodeName):
sel = om.MSelectionList()
om.MGlobal.getSelectionListByName(nodeName, sel)
dp = om.MDagPath()
sel.getDagPath(0,dp)
return dp
def UvCoordToWorld(U, V, mesh):
mfnMesh = om.MFnMesh(GetDagPath(mesh))
numFaces = mfnMesh.numPolygons()
WSpoint = om.MPoint(0.0,0.0,0.0)
util2 = om.MScriptUtil()
util2.createFromList ((U, V),2)
float2ParamUV = util2.asFloat2Ptr()
for i in range(numFaces):
try:
mfnMesh.getPointAtUV(i,WSpoint, float2ParamUV, om.MSpace.kWorld)
break; #point is in poly
except:
continue #point not found!
return WSpoint
f = UvCoordToWorld (random.random(), random.random(),
cmds.ls(sl=True,type='shape'))
print [f[0], f[1], f[2]]
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/76460376-4fc1-4266-a3ed-420e2e0ab816%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.