Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there, I use MItMeshFaceVertex iterator to get access to vertex info in a selection of faces. I try to use the "getUV" function which according to doc have this signature :
getUV(uvSet='') -> (float, float)
I tried different call most looking like this :
uv = itr.getUV('map1')
uv = itr.getUV()
Yet I got the following error :
# TypeError: in method 'MItMeshFaceVertex_getUV', argument 2 of type 'float2 &'
I saw in the C++ API that the same function in C++ have a float2 as first parameter, which is probably provided by the python wrapper.
What did I not get please?
the whole code snippet look like this :
sel = om.MSelectionList() om.MGlobal.getActiveSelectionList(sel) dag = om.MDagPath() comp = om.MObject() sel.getDagPath(0, dag, comp) itr = om.MItMeshFaceVertex(dag, comp) faces = [] vertices = [] poly_info = {} positions = om.MPointArray() uvs_u = om.MFloatArray() uvs_v = om.MFloatArray() # print '| %-15s| %-15s| %-15s' % ('Face ID', 'Object VertID', 'Face-relative VertId') while not itr.isDone(): # print '| %-15s| %-15s| %-15s' % (itr.faceId(), itr.vertId(), itr.faceVertId()) if itr.vertId() not in vertices: vertices.append(itr.vertId()) positions.append(itr.position(om.MSpace.kWorld)) if itr.hasUVs(): uv = itr.getUV('map1') uvs_u.append(uv[0]) uvs_v.append(uv[1]) if itr.faceId() not in poly_info.keys(): poly_info[itr.faceId()] = [itr.vertId()] else: poly_info[itr.faceId()].append(itr.vertId()) itr.next() mesh_fn = om.MFnMesh() # in poly_info, each key is a polygon index from the original selection # and its value is a list of indices of each vertex that makes the polygon.the # The length of this list if the amount of vertices that will make the new polygon. polygon_counts = om.MIntArray() for v in poly_info.values(): polygon_counts.append(len(v)) # vertex in list "vertices" and the MPoint in "positions" indices correspond to each other polygon_connects = om.MIntArray() for v in poly_info.values(): # our list of list of vertex indices for i in v: polygon_connects.append(vertices.index(i)) # will get corresponding position placeHolderU = om.MIntArray() placeHolderV = om.MIntArray() dummy**** = om.MObject() new_mesh = mesh_fn.create(len(vertices), len(poly_info.keys()), positions, polygon_counts, polygon_connects) if uvs_u.length() and uvs_u.length() == uvs_v.length(): mesh_fn.setUVs(uvs_u, uvs_v)
Thank you for your help! 🙂
Solved! Go to Solution.