Last active
September 20, 2016 09:48
Revisions
-
patwooky revised this gist
Sep 20, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # Written by Patrick Woo # patrickwoo@yahoo.com from pymel.core import * import random -
patwooky revised this gist
Sep 17, 2016 . No changes.There are no files selected for viewing
-
patwooky revised this gist
Sep 17, 2016 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,12 +11,12 @@ def highestObjInHierarchy(objsList=[], scrambleOrder=False): scrambleOrder - <bool> if True, will shuffle the order of the incoming list. this feature is more to test that my this function works by reordering incoming items in a random manner False by default. return - <list> the nodes that are the highest level of the selected objects ''' if scrambleOrder: random.shuffle(objsList) topLevelChildren = [] if not objsList: print 'highestObjInHierarchy: nothing in list' return [] @@ -26,14 +26,14 @@ def highestObjInHierarchy(objsList=[], scrambleOrder=False): # print 'tmpParent is', tmpParent if tmpParent == []: # print node,'is the highest in referenced objects. breaking out of for loop' if node not in objsList: topLevelChildren.append(node) continue if tmpParent[0] not in refChildren: # print node,'is the highest in referenced objects' if node not in topLevelChildren: topLevelChildren.append(node) return topLevelChildren # print highestObjInHierarchy([x for x in ls(type='reference')[0].referenceFile().nodes() if 'transform' in nodeType(x, i=True)]) print highestObjInHierarchy(ls(sl=True)) -
patwooky revised this gist
Sep 17, 2016 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,21 @@ from pymel.core import * import random def highestObjInHierarchy(objsList=[], scrambleOrder=False): ''' This function returns nodes at the highest level within the pass-in list of objects. This is accomplished by searching upwards through all selected nodes to find the nodes that have parents that are not within the selection. objsList - <list> a list of maya nodes. must be DAG nodes that belong to the scene hierarchy scrambleOrder - <bool> if True, will shuffle the order of the incoming list. this feature is more to test that my this function works by reordering incoming items in a random manner False by default. return - <list> the nodes that are the highest level of the selected objects ''' if scrambleOrder: random.shuffle(objsList) topLevelRefChildren = [] if not objsList: print 'highestObjInHierarchy: nothing in list' -
patwooky created this gist
Sep 16, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ from pymel.core import * import random def highestObjInHierarchy(objsList=[]): ''' This function returns nodes at the highest level within the pass-in list of objects. This is accomplished by searching upwards through all selected nodes to find the nodes that have parents that are not within the selection. objsList - a list of maya nodes. must be DAG nodes that belong to the scene hierarchy return - <list> the nodes that are the highest level of the selected objects ''' random.shuffle(objsList) topLevelRefChildren = [] if not objsList: print 'highestObjInHierarchy: nothing in list' return [] for node in objsList: # print 'node is',node tmpParent = [x for x in listRelatives(node,p=True)] # print 'tmpParent is', tmpParent if tmpParent == []: # print node,'is the highest in referenced objects. breaking out of for loop' if node not in topLevelRefChildren: topLevelRefChildren.append(node) continue if tmpParent[0] not in refChildren: # print node,'is the highest in referenced objects' if node not in topLevelRefChildren: topLevelRefChildren.append(node) return topLevelRefChildren # print highestObjInHierarchy([x for x in ls(type='reference')[0].referenceFile().nodes() if 'transform' in nodeType(x, i=True)]) print highestObjInHierarchy(ls(sl=True))