import maya.cmds as cmds
import re

#-----------------------------------------------
# Util Script
#-----------------------------------------------
def GetUVCoordinate(uv):
    cmds.select(uv)
    return cmds.polyEditUV(q=True)

def GetVertexNormal(vtx):
    count = len(cmds.polyNormalPerVertex(q=True, x=True))
    x = cmds.polyNormalPerVertex(q=True, x=True)
    y = cmds.polyNormalPerVertex(q=True, y=True)
    z = cmds.polyNormalPerVertex(q=True, z=True)
    avg = [0, 0, 0]
    dif = 1.0 / count
    for cnt in range(count):
        avg[0] += x[cnt]
        avg[1] += y[cnt]
        avg[2] += z[cnt]
    for cnt in range(3):
        avg[cnt] *= dif
    return avg

def GetVertexPosition(vtx):
    return cmds.pointPosition(q=True, x=True)

def GetIndices(name):
    indices = name.split('     ')[2:]
    indices[len(indices)-1] = indices[len(indices)-1].split(' ')[0]
    for i in range(len(indices)):
        indices[i] = int(indices[i])
    return indices

def GetVertexIndicesFromTriangle(f):
    vtxs = cmds.polyInfo(fv=True)
    indices = []
    for vtx in vtxs:
        indices += GetIndices(vtx)
    return indices

def GetVerticesList(model):
    count = cmds.polyEvaluate(model, v=True)
    return GetPolyElementNameList(model, count, 'vtx')

def GetFacesList(model):
    count = cmds.polyEvaluate(model, f=True)
    return GetPolyElementNameList(model, count, 'f')
    
def GetUVList(model):
    count = cmds.polyEvaluate(model, v=True)
    return GetPolyElementNameList(model, count, 'uv')

def GetPolyElementNameList(model, count, attr_name):
    attr = []
    for c in range(count):
        attr.append(model + '.' + attr_name + '[' + str(c) + ']')
    return attr


#------------------------------------------------
# Structure Base
#------------------------------------------------
class BaseStructure:
    def __init__(self, model):
        self.model = model
        self.names = None

#------------------------------------------------
# Vertex Class
#------------------------------------------------
class Vertex(BaseStructure):
    def __init__(self, model):
        BaseStructure.__init__(self, model)
        self.names = GetVerticesList(model)

s = cmds.ls(sl=True)
print GetVertexIndicesFromTriangle(s[0])

#get selecting uv coordinate
#print cmds.polyEditUV(q=True)

#get vertex position
#print cmds.pointPosition(s[0] + '.v[0]')

#get polygon count of vertex and face.
#print cmds.polyEvaluate(s[0], v=True)
#print cmds.polyEvaluate(s[0], f=True)

#check object type from joint
#print cmds.objectType(s[0], isType='joint')

#check object type from skinCluster
#print cmds.objectType(s[0], isType='skinCluster')

#get target history from list.
#print cmds.listHistory(s[0])

#get target weight
#print cmds.skinPercent('skinCluster1', s[0]+'.vtx[0]', transform='joint1', q=True)
@@ -735,24 +735,163 @@
 e, x=True)%0A%0A
+def GetIndex(name):%0A    print name%0A    m = re.search('%5C%5B%5Cw+%5C%5D', name)%0A    index = m.group().lstrip('%5B').rstrip('%5D')%0A    return int(index)%0A%0A
 def GetIndic
@@ -2308,64 +2308,256 @@
 el)%0A
-%0As = cmds.ls(sl=True)%0Aprint GetVertexIndicesFromTriangle
+        self.indices = self.ToIndices()%0A        print self.indices%0A    %0A    def ToIndices(self):%0A        indices = %5B%5D%0A        for name in self.names:%0A            indices.append(GetIndex(name))%0A        return indices%0A%0As = cmds.ls(sl=True)%0Av = Vertex
 (s%5B0

add model name to indices list