cwisbg

Scale tree

Aug 22nd, 2016
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. # scale tree
  2. from pymel.core import *
  3. #sl = selected()
  4.  
  5. """
  6. def getTrunk(jnt):# gets all children joints
  7.    jnt = jnt
  8.    jntHi = []
  9.    catcher = 100
  10.    x = 1
  11.    while jnt:
  12.        jnt = listRelatives(jnt,c=1)[:1]
  13.        branch = listRelatives(jnt,c=1)[:-1]
  14.        #print "trunk: ",jnt,"branch: ",branch
  15.        """
  16.         if x:
  17.             jntHi.append([jnt])
  18.             x = 0
  19.         else:
  20.             if len(jnt)>1:
  21.                 jntHi.append(jnt[:-1])
  22.             else:
  23.                 jntHi.append(jnt)
  24.         jnt = listRelatives(jnt,c=1)
  25.         if len(jnt)>1:
  26.             jntHi.append([jnt[0]])
  27.             jnt = listRelatives(jnt[0],c=1)
  28.         """  
  29.        if catcher == 0:
  30.            break
  31.        catcher -= 1
  32. """
  33.  
  34.        
  35. def getBranch(jnt):# main recurser
  36.     trunk = jnt
  37.     trunkHi = []
  38.     branches = []
  39.     catcher = 100
  40.     x = 1
  41.     while trunk:
  42.         trunk = listRelatives(trunk,c=1)[:1]
  43.         branch = listRelatives(trunk,c=1)
  44.         print branch
  45.         if trunk:
  46.             trunkHi.append(trunk)
  47.         if branch:
  48.             branches.append(branch)
  49.         # just in case  
  50.         if catcher == 0:
  51.             break
  52.         catcher -= 1
  53.         #------------
  54.        
  55.     return trunkHi, branches
  56. for s in sl:
  57.     branch = s
  58.     catcher = 100
  59.     search = 1
  60.     while search:
  61.         trunk, branch = getBranch(branch)
  62.         #print "trunk ", trunk, "branch ", branch
  63.         if not branch:
  64.             search = 0
  65.             break
  66.         # just in case  
  67.         if catcher == 0:
  68.             break
  69.         catcher -= 1
  70.         #------------
  71.              
  72.     #trunk = getTrunk(s)
  73.    
  74.     #print branch
  75.     """
  76.    for t in trunk:
  77.        l = spaceLocator(n=str(t)+"_save")
  78.        pc = parentConstraint(t,l)
  79.        delete(pc)
  80.    """
Advertisement
Add Comment
Please, Sign In to add comment