Skip to content

Instantly share code, notes, and snippets.

@justinfx
Created November 27, 2011 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinfx/1398060 to your computer and use it in GitHub Desktop.
Save justinfx/1398060 to your computer and use it in GitHub Desktop.
Selecting staggered vert/face from start and stop original selection
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