Created
August 29, 2015 11:18
-
-
Save SEVEZ/b09d7f36dab690e6f11e to your computer and use it in GitHub Desktop.
Convert between creased and hard edges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' [Crease To Normal] | |
Created on 23.07.2012 | |
edgeCreaser - uses edge Crease info to make it hard edge, or use Hard edge info to make edge crease. | |
@author: Serge Scherbakov | |
''' | |
import maya.cmds as cmds | |
class edgeCreaser(): | |
@staticmethod | |
def apply(mode = 'c2n'): | |
hardList = [] | |
softList = [] | |
selection = cmds.ls(sl = True) | |
el = cmds.polyListComponentConversion(toEdge = True) | |
cmds.select (el, r = True) | |
edgeList = cmds.ls( sl = True, fl = True) | |
if mode == 'c2n': | |
for edge in edgeList: | |
if cmds.polyCrease(edge, q = True, value = True)[0] > 0.0: | |
hardList.append(edge) | |
else: | |
softList.append(edge) | |
cmds.select(selection, r = True) | |
vertsList = cmds.polyListComponentConversion(toVertex = True) | |
cmds.select(vertsList , r = True) | |
cmds.polyNormalPerVertex(ufn = True) | |
if hardList: | |
cmds.polySoftEdge(hardList, a = 0) | |
if softList: | |
cmds.polySoftEdge(softList, a = 180) | |
if mode == 'n2c': | |
for edge in edgeList: | |
eInfo = cmds.polyInfo(edge, ev = True) | |
if 'Hard' in eInfo[0]: | |
hardList.append(edge) | |
else: | |
softList.append(edge) | |
if softList: | |
cmds.polyCrease(softList, operation = 1) | |
if hardList: | |
cmds.polyCrease(hardList, value = 10) | |
cmds.select(selection, r = True) | |
edgeCreaser.apply('c2n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment