Created
April 3, 2018 04:02
-
-
Save zewt/4f5e54d20839697c94df0afbf67e41a9 to your computer and use it in GitHub Desktop.
Aborted Maya pick walking script
This file contains hidden or 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 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