Ejemplo n.º 1
0
    def Action_Apply(self):
        maya_cmds.undoInfo(openChunk=True)
        try:
            items = self.window.Text_Items.toPlainText().strip().split('\n')
            objects = list(
                set([items[i].split('.')[0] for i in xrange(len(items))]))

            amount = self.window.Int_Amount.value()
            iterations = self.window.Int_Iterations.value()
            blend = self.window.Float_Blend.value() * -1.0

            for i in xrange(len(objects)):
                for _ in xrange(iterations):
                    duplicate = maya_cmds.duplicate(objects[i],
                                                    returnRootsOnly=True)
                    maya_cmds.polyAverageVertex([
                        item.replace(objects[i], duplicate[0])
                        for item in items if objects[i] in item
                    ],
                                                caching=True,
                                                iterations=amount)
                    maya_cmds.blendShape(duplicate,
                                         objects[i],
                                         envelope=blend,
                                         weight=[0, 1.0])
                    maya_cmds.delete(duplicate)
        except Exception as e:
            print >> stderr, str(e)
        maya_cmds.undoInfo(closeChunk=True)
Ejemplo n.º 2
0
def averageInsideVertices(mesh):
    """
  This function grabs the inside vertices of the mesh and average out the distance between
  Args:
    mesh: The mesh to average vertices
  """
    cmds.select(mesh)
    cmds.polySelectConstraint(m=3, t=0x0001, w=2)
    cmds.polySelectConstraint(dis=True)
    cmds.polyAverageVertex(i=10, ch=0)
Ejemplo n.º 3
0
"""
rhuber
select verts
middle mouse drag
"""

import maya.cmds as cmds
import maya.OpenMaya as OpenMaya

if cmds.filterExpand(sm=31): #31 = verts
    cmds.polyAverageVertex(i=0, ch=True)
    pAV = cmds.listHistory()[1] + ".iterations" 
    cmds.dragAttrContext('myDragAttrContext', e=True, ct=pAV) 
    cmds.setToolTo('myDragAttrContext')

else:
    OpenMaya.MGlobal.displayWarning("At least one vertex must be selected.")
Ejemplo n.º 4
0
def polyAverageVertex(*args, **kwargs):
    res = cmds.polyAverageVertex(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
Ejemplo n.º 5
0
def gridFill():
    ####        Setting ordered selection as true in the preferences        ####

    cmds.selectPref(trackSelectionOrder=True)
    userOffset = cmds.intField(offsetBox, q=1, v=1)
    userDivision = cmds.intField(divisions, q=1, v=1)
    relax = cmds.optionMenu(relaxChoice, q=1, v=1)

    ####        Getting the original selection          ####
    originalSelection = (cmds.ls(selection=True, flatten=True))
    # Storing the number of vertices in order to be able to relax the new created ones
    cmds.select(clear=True)
    mel.eval("invertSelection;")
    cmds.polyListComponentConversion(fromEdge=True, toVertex=True)
    verticesForExclusion = cmds.polyListComponentConversion(fromEdge=True,
                                                            toVertex=True)
    cmds.select(verticesForExclusion)

    cmds.select(originalSelection)

    #####       Selection changes       ####

    i = 0
    selectionGrowList = []

    mel.eval("invertSelection;")
    invertedOriginal = (cmds.ls(selection=True, flatten=True))

    cmds.select(clear=True)

    # Get the first edge of the border selected
    cmds.select(originalSelection[userOffset + 1])
    if len(originalSelection) % 4 == 0:
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        cmds.select(invertedOriginal, deselect=True)
        originalOddSelection = (cmds.ls(selection=True, flatten=True))
        cmds.select(clear=True)
        cmds.select(originalOddSelection[0], originalOddSelection[1])

    # Grow selection until the whole border is selected
    while i < (len(originalSelection) / 2 - 1):
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        selectionGrowList.append(cmds.ls(selection=True, flatten=True))
        i += 1

    # Finding the two middle edges of the list
    midHalf = (i / 2)
    midSubstract = (i / 2) - 2

    # Reset i value
    i = 0

    ####        Selecting the two opposite edges suites         ####

    # Selecting the first two opposite edges
    cmds.select(clear=True)
    cmds.select(selectionGrowList[midHalf])
    cmds.select(selectionGrowList[midSubstract], deselect=True)
    cmds.select(invertedOriginal, deselect=True)

    # Growing the selection by the number of user divisions
    while i < userDivision - 4:
        mel.eval('select `ls -sl`;PolySelectTraverse 1;select `ls -sl`;')
        i += 1
    cmds.select(invertedOriginal, deselect=True)
    # reset i
    i = 0

    ####        Getting the number of division on the bridge           ####
    firstBridge = cmds.ls(selection=True, flatten=True)

    # The number of divisions needed is equal to the remaining edges on the original edge loop divided by 2 and minus 3
    divisionsNeeded = (len(originalSelection) - len(firstBridge) - 4) / 2 - 1

    # Bridging the first loop and dividing it
    cmds.polyBridgeEdge(divisions=divisionsNeeded)

    # now need to find a way to select the remaining edge loops in order to bridge them
    # The shrink selection around loop should work
    # Should find indications in the cmds.polySelectConstraint( pp=1 ) documentation

    # Get the first edge of the last two bridges
    cmds.select(clear=True)
    cmds.select(originalSelection)
    cmds.select(firstBridge, deselect=True)

    otherBridge = cmds.ls(selection=True, flatten=True)

    # Minus border edges
    mel.eval('select `ls -sl`;PolySelectTraverse 6; select `ls -sl`;')
    actualBridge = cmds.ls(selection=True, flatten=True)

    #Getting border edges to remove for the last two bridges
    cmds.select(clear=True)
    cmds.select(otherBridge)
    cmds.select(actualBridge, deselect=True)
    minusBridge = cmds.ls(selection=True, flatten=True)

    #####        Selecting the remaining bridges           ####

    cmds.select(clear=True)
    cmds.select(otherBridge[0])
    # Selecting the whole loop
    cmds.polySelectSp(loop=True)
    secondBridge = cmds.ls(selection=True, flatten=True)

    # Deselect the minusBridge
    cmds.select(minusBridge, deselect=True)

    cmds.polyBridgeEdge(divisions=0)

    #LastBridge
    cmds.select(clear=True)
    cmds.select(otherBridge)
    #Selecting a single edge from this selection, otherwise the polySelectSp(loop=True) does not work
    cmds.select(secondBridge, deselect=True)
    lastBridge = cmds.ls(selection=True, flatten=True)

    cmds.select(clear=True)
    cmds.select(lastBridge[0])

    # Selecting the whole loop
    cmds.polySelectSp(loop=True)

    # Deselect the minusBridge
    cmds.select(minusBridge, deselect=True)

    cmds.polyBridgeEdge(divisions=0)

    ####        Relax the new vertices      ####
    cmds.select(clear=True)

    if relax == "Yes":
        mel.eval("setSelectMode components Components;")
        mel.eval(
            "selectType -smp 0 -sme 0 -smf 0 -smu 0 -pv 1 -pe 0 -pf 0 -puv 0;")
        cmds.select(verticesForExclusion)
        mel.eval("invertSelection;")
        verticesForRelax = []
        verticesForRelax = cmds.ls(selection=True, flatten=True)
        cmds.polyAverageVertex(verticesForRelax, iterations=100)
        mel.eval(
            "selectType -smp 0 -sme 0 -smf 0 -smu 0 -pv 0 -pe 1 -pf 0 -puv 0;")
        cmds.select(clear=True)
Ejemplo n.º 6
0
 def averageVertex( evt=0 ):
     mel.eval( "SGMPlugMod01Command -upc" )
     cmds.polyAverageVertex()
     mel.eval( "SGMPlugMod01Command -upc" )
Ejemplo n.º 7
0
def eroder(repeat=1, iter=1):
    for i in range(0, repeat):
        mc.polyAverageVertex(i=iter)
        ch()
Ejemplo n.º 8
0
def eroder(repeat=1, iter=1):
    for i in range(0,repeat):
        mc.polyAverageVertex(i=iter)
        ch()
Ejemplo n.º 9
0
 def averageVertex(evt=0):
     mel.eval("SGMPlugMod01Command -upc")
     cmds.polyAverageVertex()
     mel.eval("SGMPlugMod01Command -upc")