Hi, is there a simple way to iterate over all UV border edges in Open Maya?
I’m currently converting a MEL script to OpenMaya to convert all border and UV edges to hard shading and all other edges to soft shading.
This is what I have so far:
import maya.api.OpenMaya as om2
selection_list = om.MGlobal.getActiveSelectionList()
selection_iter = om.MItSelectionList(selection_list)
while not selection_iter.isDone():
node = selection_iter.getDependNode()
mesh = om2.MFnMesh(selection_iter.getDagPath())
vertices_with_same_uvs = []
vertex_iter = om2.MItMeshVertex(node)
while not vertex_iter.isDone():
indices = vertex_iter.getUVIndices()
if all(x==indices[0] for x in indices):
vertices_with_same_uvs.append(vertex_iter.index())
vertex_iter.next()
edge_iter = om2.MItMeshEdge(node)
while not edge_iter.isDone():
if edge_iter.onBoundary():
mesh.setEdgeSmoothing(edge_iter.index(), False)
elif edge_iter.vertexId(0) not in vertices_with_same_uvs and edge_iter.vertexId(1) not in vertices_with_same_uvs:
mesh.setEdgeSmoothing(edge_iter.index(), False)
else:
mesh.setEdgeSmoothing(edge_iter.index(), True)
edge_iter.next()
selection_iter.next()