Skip to content

Instantly share code, notes, and snippets.

@kanishk2391
Last active March 16, 2021 03:24
Show Gist options
  • Save kanishk2391/a8e883298c6d7836f01a to your computer and use it in GitHub Desktop.
Save kanishk2391/a8e883298c6d7836f01a to your computer and use it in GitHub Desktop.
Reconstruct Subdiv for Maya
#---------Reconstruct Subdiv Script for Maya----------
#Script by - Kanishk Chouhan
#Email - kanishk2391@gmail.com
#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)
@Nzo
Copy link

Nzo commented Apr 6, 2020

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.
unsmooth_sphere

Works well with polyCube though.
Cheers
Nzo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment