I have files that have been tagged with a hard edge from another program, but the value is not correct. I want to select those tagged edges and do a polyCrease with a val of 2. However, i dont want to select them manually because i have around 500 sub objects all with the same problem.
Walk a list of all the verts and convert each one to vert normals. Anything that converts to more than one normal is on a hard edge and can be re-smoothed. You can convert to edges if you want to with polyListComponentConversion.
You have a couple of options. You can use Select > Select Using Constraints to restrict the current (or future) selection to hard edges.
The command equivalent of that is cmds.polySelectConstraint. This still requires a selection to operate on, so you’ll have to do something like this:
import maya.OpenMaya as om
sel = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sel)
selIt = om.MItSelectionList(sel)
dagPath = om.MDagPath()
# Iterate over each selected object
while not selIt.isDone():
selIt.getDagPath(dagPath)
edgeIt = om.MItMeshEdge(dagPath)
hardEdges = set()
# Iterate over all the edges
while not edgeIt.isDone():
# Tests whether the edge is hard or smooth
if not edgeIt.isSmooth():
hardEdges.add(edgeIt.index())
edgeIt.next()
# Do stuff with hardEdge
selIt.next()