Skip to content

Instantly share code, notes, and snippets.

@zewt
Created April 3, 2018 04:02
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 zewt/4f5e54d20839697c94df0afbf67e41a9 to your computer and use it in GitHub Desktop.
Save zewt/4f5e54d20839697c94df0afbf67e41a9 to your computer and use it in GitHub Desktop.
Aborted Maya pick walking script
import sys
import pymel.core as pm
def pick_walk(direction, add=False):
nodes = pm.ls(sl=True)
new_nodes = []
non_dag_nodes = []
for node in nodes:
# Make a list of non-DAG nodes.
if not isinstance(node, pm.nodetypes.DagNode):
non_dag_nodes.append(node)
continue
pm.select(node, ne=True)
pm.pickWalk(direction=direction)
new_nodes.extend(pm.ls(sl=True))
pm.select(d=True)
# If any non-DAG objects were selected, like components, use the regular pick walk command to handle them.
if non_dag_nodes:
pm.select(non_dag_nodes)
pm.pickWalk(direction=direction)
# Add our individual pick walking results.
pm.select(new_nodes) #, ne=True, add=True)
# If add is true, reselect the original selection.
if add:
pm.select(nodes, ne=True, add=True)
pick_walk('down', False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment