Created
November 27, 2011 20:00
-
-
Save justinfx/1398060 to your computer and use it in GitHub Desktop.
Selecting staggered vert/face from start and stop original selection
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
import re | |
import maya.cmds as cmds | |
def getSelectedInts(): | |
rx = re.compile(r'\[(\d+)\]$') | |
intList = [] | |
sel = cmds.ls(sl=True) | |
if not sel: | |
return "", [] | |
obj = sel[0].split('.')[0] | |
for v in cmds.ls(sl=True): | |
search = rx.search(v) | |
if search: | |
num = search.group(1) | |
intList.append( int(num) ) | |
return obj, intList | |
def getVertices(): | |
obj, vList = getSelectedInts() | |
edges = cmds.polySelect(obj, q=True, shortestEdgePath=vList, asSelectString=True) | |
cmds.select(edges, replace=True) | |
lines = cmds.polyInfo(edgeToVertex=True) | |
items = [] | |
for line in lines: | |
vList = line.strip().split()[-2:] | |
for v in vList: | |
path = '%s.vtx[%s]' % (obj, v) | |
if not path in items: | |
items.append(path) | |
return items | |
def getFaces(): | |
obj, fList = getSelectedInts() | |
faces = cmds.polySelect(obj, shortestFacePath=fList, asSelectString=True) | |
return faces | |
def main(): | |
# do selection | |
selectBy = 2 | |
#items = getVertices() | |
items = getFaces() | |
cmds.select(clear=True) | |
for i in xrange( 0, len(items), selectBy ): | |
cmds.select(items[i], add=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment