Last active
March 16, 2021 03:24
-
-
Save kanishk2391/a8e883298c6d7836f01a to your computer and use it in GitHub Desktop.
Reconstruct Subdiv for Maya
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
#---------Reconstruct Subdiv Script for Maya---------- | |
#Script by - Kanishk Chouhan | |
#Email - [email protected] | |
#Blog - www.pixel-architect.blogspot.com | |
#Description - | |
#This script allows u to reverse the result of smooth operation in maya after deleting the history | |
#It also preserves the original UV of the mesh | |
#Select the mesh u want to unsmooth and execute the script | |
#Script might take some time to execute depending on the polycount... | |
import maya.cmds as cmds | |
import maya.mel as mel | |
#Get the selected mesh | |
selectedMesh=cmds.ls( selection=True )[0] | |
#Get the vertex count i.e. vertex id of last vertex... | |
vertexCount=cmds.polyEvaluate( v=True ) | |
vertexId = selectedMesh+'.vtx['+str(vertexCount)+']' | |
cmds.select(vertexId) | |
#Convert selection to edges... | |
x=cmds.polyListComponentConversion( fv=True,te=True ) | |
cmds.select(x) | |
#get the edges number... | |
k=x[0].rfind(']') | |
l=x[0].rfind('[') | |
start = x[0][l+1:] | |
edges = str(start[:-1]) | |
colon = edges.split(':') | |
#Select edge loops and rings... | |
mel.eval('SelectEdgeLoopSp;') | |
mel.eval('polySelectEdgesEveryN "edgeRing" 2;') | |
mel.eval('SelectEdgeLoopSp;') | |
mel.eval('SelectEdgeLoopSp;') | |
mel.eval('SelectEdgeLoopSp;') | |
mel.eval('polySelectEdgesEveryN "edgeRing" 2;') | |
#Delete the selected edgeloops | |
cmds.polyDelEdge( cv=True ) | |
cmds.select(selectedMesh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Kanishk,
Thanks for sharing this tool. Just starting to use it. Work well in some condition, but not so much in other.

Create a polySphere > apply polysmooth > delete history > unsmooth.
Works well with polyCube though.
Cheers
Nzo