cwisbg

TreeGenv0

Oct 9th, 2015
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. from pymel.core import *
  2. def grpr(name):
  3.     g = ls(name)
  4.     if g:
  5.         delete(g)
  6.     g = group(n=name,em=1)
  7.     return g
  8. def getBranches(branches):
  9.     branches = [branches]
  10.     lctList = []# list to save the locations
  11.     catcher = 1000
  12.     while branches:
  13.         # In case I suck
  14.         if catcher == 0:
  15.             break
  16.         catcher -= 1          
  17.         source = branches[0]# source starts as root branch
  18.         children = listRelatives(branches[0],c=1)# check for branches
  19.         if children:# if it has children              
  20.             if len(children) > 1: # if it has multiple children loop though and add to branching array
  21.                 for c in children:
  22.                     branches.append(c)
  23.             else: #if only one child
  24.                 branches.append(children[0])
  25.         else:# if no children then END
  26.             pass
  27.         lctList.append(source)
  28.         branches.remove(source)# remove finished branch from branching list
  29.     return lctList
  30. sl = selected()  
  31. grp = grpr("jntLocators")                
  32. for s in sl:
  33.     branches = getBranches(s)
  34.     for b in branches:      
  35.         l = spaceLocator()
  36.         pc = parentConstraint(b,l)
  37.         delete(pc)
  38.         parent(l,grp)
Advertisement
Add Comment
Please, Sign In to add comment