Advertisement
Flynny85

RigBox Alpha Maya K Flynn

Nov 6th, 2015
2,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 121.13 KB | None | 0 0
  1. #######################################################################################
  2. #   #   Rig box 2015 : k flynn
  3. #   #   A simple / complex tool for creating multi faceted rigs with just a few clicks
  4. #   #   Full complex rigs in under an hour is the promise!
  5. #   #   While trying to maintain a simplicity of lego blocks
  6. #   #   enjoy
  7. #   #   Vers:v.12
  8. #######################################################################################
  9. # Features:
  10. #   # Unity compatible scaling.
  11. #   # Simple rig creation and editing (Just re-build from the guide objects) .
  12. #   # simple layout in Maya for compatibility and editing
  13. #  
  14. #   # Follows the rotation order set by the guide objects for all items created there after..
  15. #   # Independent joint location and controller pivot set up in the guide ( edit the local joint locator of each guide object to set the joint position to something other than 0,0,0 )
  16. #  
  17. #   # eye ball / aim /
  18.  
  19. #   # FK Features:
  20. #       # Local joint breaking behaviour as an option. ( under extra options as 'local' )
  21. #       # Follow un-follow of rotation translation for each controller as a default option.
  22. #       # FK Scale of each controller..
  23. #      
  24. #   #IK Features:
  25. #      
  26. #       # Local IK Control
  27. #
  28. #   # TO IMPLEMENT SO FAR (in order):
  29. #   # Implement new way of doing the join pivot locator? must be an easier way..
  30. #   # IK Breakable elbow.
  31. #   # Mirror setup easier
  32. #   # Maya compatible Rig scaling ( uniform )
  33. #   # foot roll / hand roll setup
  34. #   # More Control variety
  35. #   # IK Stretch
  36. #   # Automatic colour / naming of controls
  37. #   # Control bundles to save time
  38. #   # Bendy / Spline IK
  39. #   # Twist Joints / set-up
  40. #   # IK FK Matching
  41.  
  42. #   # blink setup
  43. ########################################################################################
  44.  
  45. # rules for tds to understand:
  46. # JOINTS: by default  _Jnt , IK_MAIN_Jnt , IK_BREAK_Jnt and FK_Jnt.  (all of Suffix_Joints below) joint chains will always be made..
  47. # ..this is for simplicity so the so the main chain will always have a ik fk attribute to edit.
  48.  
  49.  
  50.  
  51. # need to break the processes down more, its getting too complicated now, too many special cases!
  52. # -- added the ability to set the colour of controls before creating them on the fly..
  53. # fixed the ik start controller having rotation still available despite being constrained, now rotations are locked
  54. # fixed visibility to now be locked on all controls.
  55. # fk controls should maybe only take the pivot of the joints? to avoid strangeness?  --fixed!
  56. # maybe add option for floater joints? they ignore the heirachy except for one parent? but the guides are all parented the right way.. would be good for unity fancy scaling..
  57. # also perhaps have a influenced by grandfather option? great for feathers/ tails.. etc
  58. # perhaps all joints should have ikfk by default?
  59. # also, perhaps all control pins above should link to a ik and fk pin of the parent...
  60. # ..while checking the current ikfk status of that joint and parent appropriately..
  61.  
  62. #
  63. # mirror tool works better, now renames both control and local jnt and also does local rotation on localjnt.
  64. # footroll almost finished!
  65. # started on footroll
  66. # eye aim sorted, all eyeaim controls need to be in the parent hierachy of the eye (at least nested 2 parents up..)
  67. # recent fixes in order: recent progress:
  68. # ###### Local hip etc controls etc should control the ik pins! --fixed
  69. # Updated the constraining of none ik or fk item controls and joint heirechys
  70. # cleaned up grouping function slightly..
  71. # work finished on setting up ik items space switching!
  72. # started work on space switching, need to set-up how I will do constraints.
  73. # fixed pins for fk items not following the joint of the ikfk above instead of the controls (pulling fingers away from hand etc..)
  74.  
  75.  
  76. import maya.cmds as cmds
  77. Width_Height_Open = [ 250 , 50 ]
  78. Red_Btn_Col = ( .73 , .29 , .29 )
  79. Bright_Red_Btn_Col = ( 1 , .2 , .2 )
  80. Yel_Btn_Col = ( .84 , .76 , .31 )
  81. Grn_Btn_Col = ( .34 , .76 , .31 )
  82. Drk_Grey = [ .3 , .3 , .3 ]
  83. Lte_Grey = [ .47 , .45 , .45 ]
  84.  
  85.  
  86.  
  87. pass # Attribute names: # Attribute names: # Attribute names: # Attribute names:
  88. Suffix_Joints = [ '_Jnt' , '_Jnt_IK_Break' , '_Jnt_FK' , '_Jnt_IK_Main' ] # joint chain names...
  89. IK_FK_Blend_Atr = [ 'IK_0_to_FK_1_Blend' , 'IK_FK_RevBlend' ]
  90. Follow_Channel_Names = [ 'Follow__Trans' , 'Follow__Rota' ]
  91. pass # Attribute names: # Attribute names: # Attribute names: # Attribute names:
  92.  
  93. All_Controls_Made = []
  94. Global_Scene_Size = 25
  95. Global_Local_Control_Size = .9
  96. Global_Colour = 0
  97.  
  98. MainGrp = 'Character'
  99.  
  100. RigBox_All_Grps = [
  101. 'Character_Rig_Guide' ,
  102. 'Character_Rig_Mesh' ,
  103. 'Character_Rig_Controls' ,
  104. 'Character_Rig_BitsDoNotDelete' ,
  105. 'Character_Rig_Pins' ]
  106.  
  107. RigBox_All_Grps_Vis = [ 0 , 1 , 1 , 0 , 0 ]
  108. RigBox_All_Grps_InheritTransform = [ 1 , 0 , 1 , 1 , 1 ]
  109.  
  110. Joint_Grps = [
  111. 'Character_Rig_Joints' ,
  112. 'Character_Rig_Joints_FK' ,
  113. 'Character_Rig_Joints_IK_breakable' ,
  114. 'Character_Rig_Joints_IK_Main' ]
  115.  
  116. Joint_Grps_Vis = [ 0 , 0 , 0 , 0 ]
  117. Joint_Grps_InheritTransform = [ 1 , 1 , 1 , 1 ]
  118.  
  119. RigBox_All_Grps.extend( Joint_Grps )
  120. RigBox_All_Grps_Vis.extend( Joint_Grps_Vis )
  121. RigBox_All_Grps_InheritTransform.extend( Joint_Grps_InheritTransform )
  122.  
  123. System_Types = [
  124. 'IK' ,
  125. 'FK' ,
  126. 'IKFK' ,
  127. '_' ,
  128. 'PoleV' ,
  129. 'Aim_Target' ,
  130. 'Aim_Affected' ] # the options used and added to the attributes..
  131.  
  132.  
  133. Pin_Types = [
  134. '_' ,
  135. 'World' ,
  136. 'Hip' ,
  137. 'Chest' ,
  138. 'L_Hand' ,
  139. 'L_Elbow_Pole' ,
  140. 'R_Hand' ,
  141. 'R_Elbow_Pole' ,
  142. 'Head' ,
  143. 'L_Foot' ,
  144. 'L_Knee_Pole' ,
  145. 'R_Foot' ,
  146. 'R_Knee_Pole' ,
  147. 'Misc' ,
  148. 'EyeAim' ] # values to declare what certain items could be..
  149.  
  150.  
  151. Pin_Type_Targets = [
  152. ['_' ] ,
  153. ['_' ] ,
  154. ['World' ] ,
  155. ['World' , 'Hip' ] ,
  156. ['World' , 'Hip' , 'Chest' , 'Head'  ] ,
  157. ['World' , 'Hip' , 'Chest' , 'L_Hand' ] ,
  158. ['World' , 'Hip' , 'Chest' , 'Head'  ] ,
  159. ['World' , 'Hip' , 'Chest' , 'R_Hand' ] ,
  160. ['World' , 'Hip' , 'Chest' , 'R_Hand' , 'L_Hand' ] ,
  161. ['World' , 'Hip'  ] ,
  162. ['World' , 'Hip' , 'Chest' , 'L_Foot' ] ,
  163. ['World' , 'Hip'  ] ,
  164. ['World' , 'Hip' , 'Chest' , 'R_Foot' ] ,
  165. ['World' , 'Hip' , 'Chest' , 'Head' , 'L_Hand' , 'L_Foot' , 'R_Hand' , 'R_Foot' ] ,  
  166. ['World' , 'Hip' , 'Chest' , 'Head' ] ]
  167.  
  168.  
  169.  
  170.  
  171. Extra_Types = [
  172. '_' ,
  173. 'Local' ,
  174. 'Jiggle' ,
  175. 'Roll_Toe' ,
  176. 'Roll_Ball' ,
  177. 'Roll_Heel' ]
  178.  
  179. Axis_Channels = [
  180. 'X+' ,
  181. 'Y+' ,
  182. 'Z+' ,
  183. 'X-' ,
  184. 'Y-' ,
  185. 'Z-' ,
  186. ]
  187.  
  188.  
  189.  
  190. Extra_Options = [ 'IF_IK_allow_Breakable_IK_Setup' , 'IF_IK_allow_IK_Stretch_Opt' ]
  191. Extra_Options_Values = [ 'Yes' , 'No' ]
  192. Split_Char = ':'
  193.  
  194.  
  195.  
  196. pass ## Biped Arm Simple Setup:
  197. BipedArm_Naming =   [ 'L_Clavicle' , 'L_Shoulder' , 'L_Elbow' , 'L_Hand' ]
  198. BipedArm_Opts =     [ 'FK' ,        'IKFK' ,        'IKFK' ,    'IKFK' ]
  199. BipedArm_Pins =     [ '_' ,         '_' ,           '_' ,       'L_Hand' ]
  200. BipedArm_Xforms =   [ [0,0,0,-10,0,-90] , [0,2.5,0,10,0,-25]    , [0,5,0,20,0,0] , [0,5,0,0,0,0] ]
  201.  
  202. pass ## Biped Leg Simple Setup:
  203. BipedLeg_Naming =   [ 'L_Leg' , 'L_Knee' , 'L_Ankle' , 'L_Toes' ]
  204. BipedLeg_Opts =     [ 'IKFK' ,      'IKFK' ,        'IKFK' ,    'FK' ]
  205. BipedLeg_Pins =     [ '_' ,         '_' ,           '_' ,       'L_Foot' ]
  206. BipedLeg_Xforms =   [ [0,0,0,180,0,0] , [0,5,0,10,0,0]  , [0,5,0,-100,0,0] , [0,2.5,0,0,0,0] ]
  207.  
  208. pass ## Biped FK Back Simple Setup:
  209. BipedFKBack_Naming =    [ 'Hip' ,   'Back_01' , 'Back_02' , 'Chest' , 'Neck' , 'Head' ]
  210. BipedFKBack_Opts =  [ 'FK' ,    'FK' ,     'FK' ,      'FK'      , 'FK'  , 'FK' ]
  211. BipedFKBack_Pins =  [ 'Hip' ,   '_' ,       '_' ,       'Chest'  , '_'   , 'Head' ]
  212. BipedFKBack_Xforms =    [ [0,0,0,0,0,0] , [0,1.5,0,-7,0,0]  , [0,1.5,0,7,0,0] , [0,1.5,0,9,0,0] , [0,3,0,10,0,0] , [0,2,0,-16,0,0] ]
  213.  
  214.  
  215.  
  216. # BipedLeg_Naming = [ 'L_Clavicle' , 'L_Shoulder' , 'L_Knee' , 'L_Ankle' , 'L_Toe' ]
  217. # BipedLeg_Opts = [ 'IKFK' , 'IKFK' , 'IKFK' , 'IKFK' , 'L_Toe' ]
  218. # BipedLeg_Pins = [ '_' , '_' , '_' , 'L_Foot' , '_' ]
  219.  
  220. # BipedLeg_Naming = [ 'L_Clavicle' , 'L_Shoulder' , 'L_Knee' , 'L_Ankle' , 'L_Toe' ]
  221. # BipedLeg_Opts = [ 'IKFK' , 'IKFK' , 'IKFK' , 'IKFK' , 'L_Toe' ]
  222. # BipedLeg_Pins = [ '_' , '_' , '_' , 'L_Foot' , '_' ]
  223.  
  224.  
  225.  
  226.  
  227.  
  228. def Rig_Box_Win_cmd():
  229.     Rig_Box_Win = "Rig_Box_Win"
  230.  
  231.     if cmds.window('Rig_Box_Win', exists=True):
  232.         cmds.deleteUI('Rig_Box_Win', window=True)
  233.         cmds.windowPref( 'Rig_Box_Win', remove=True )
  234.     cmds.window( 'Rig_Box_Win' ,  rtf=True , toolbox=True , widthHeight = Width_Height_Open )
  235.    
  236.     cmds.rowColumnLayout( 'Rig_Box_MainWin' , numberOfColumns = 1  )   
  237.     cmds.text( label = '-: RigBox 2014 :-' , align = 'center' )
  238.    
  239.    
  240.     cmds.intSliderGrp( 'Rig_Box_UnitSize_Field' , field = True , label='Overall Scene Size' , min = 1 , max = 1000 , value = 25 , step=10  , width = Width_Height_Open[0] , parent = 'Rig_Box_MainWin' , cc = 'RigBox_SceneSize()' )   
  241.     cmds.floatSliderGrp( 'Rig_Box_LocalControlSize_Field' , field = True , label='Local Control Size' , max = 2.2, min = .22 , v = .9 , width = Width_Height_Open[0] , parent = 'Rig_Box_MainWin' , cc = 'RigBox_LocalConrolSize()')   
  242.    
  243.    
  244.     cmds.frameLayout( 'RigBox_LimbTypes' , label = 'Limb Types' , vis = True , cll = True , cl = True , parent = 'Rig_Box_MainWin' , width = Width_Height_Open[0] )
  245.    
  246.     cmds.rowColumnLayout( numberOfColumns = 3  )   
  247.     cmds.button( label = 'Biped Leg ' , command = 'RigBox_Build_BipedLeg()' , width = ( Width_Height_Open[0] / 3 ) )
  248.     # cmds.button( label = 'Dog Leg ' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
  249.     # cmds.button( label = 'Tentacle ' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
  250.    
  251.     cmds.button( label = 'Biped Arm ' , command = 'RigBox_Build_BipedArm()' , width = ( Width_Height_Open[0] / 3 ) )
  252.     cmds.button( label = 'Biped FK Back' , command = 'RigBox_Build_BipedFKBack()' , width = ( Width_Height_Open[0] / 3 ) )
  253.     # cmds.button( label = 'Simple Hand' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
  254.     # cmds.button( label = 'Simple Head' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
  255.    
  256.    
  257.    
  258.     cmds.frameLayout( 'RigBox_ExtraTypes' , label = 'Extra Controls' , vis = True , cll = True , cl = True , parent = 'Rig_Box_MainWin' , width = Width_Height_Open[0] )
  259.    
  260.     cmds.rowColumnLayout( 'Rig_Box_MainCol_1' , numberOfColumns = 3  , parent = 'RigBox_ExtraTypes' )  
  261.    
  262.  
  263.     cmds.button( label = 'Circle (lo) ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Circle_Low()' , width = ( Width_Height_Open[0] / 3 ) )
  264.     cmds.button( label = 'Circle (hi) ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Circle_Hi()' , width = ( Width_Height_Open[0] / 3 ) )
  265.  
  266.  
  267.     cmds.button( label = 'Ball obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Ball()' , width = ( Width_Height_Open[0] / 3 ) )
  268.     cmds.button( label = 'Square obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Square()' , width = ( Width_Height_Open[0] / 3 ) ) 
  269.    
  270.    
  271.     cmds.button( label = 'Pole Vector obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_PoleV("Manual")' , width = ( Width_Height_Open[0] / 3 ) ) 
  272.  
  273.    
  274.  
  275.    
  276.     cmds.text( label = '-: Additional :-' , align='center' , parent = 'Rig_Box_MainWin' )  
  277.  
  278.  
  279.     ##colour options
  280.     cmds.frameLayout( 'Rig_Box_ColourOptsTab' , label = 'Extra Colour options' , vis = True , cll = True , cl = False , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
  281.     cmds.rowColumnLayout( 'Rig_Box_MainCol_Colour' , numberOfColumns = 15,  parent = 'Rig_Box_ColourOptsTab' )     
  282.  
  283.     ##guide object options
  284.     cmds.frameLayout( 'Rig_Box_AimOptsTab' , label = 'Extra Guide options' , vis = True , cll = True , cl = True , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
  285.     cmds.rowColumnLayout( 'Rig_Box_MainCol_Axis' , numberOfColumns = 3 ,  parent = 'Rig_Box_AimOptsTab' )      
  286.     cmds.rowColumnLayout( 'Rig_Box_MainCol_Mir' , numberOfColumns = 1 ,  parent = 'Rig_Box_AimOptsTab' )       
  287.  
  288.     cmds.button( label = 'Move Selected PoleVector' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'Rigbox_IKPole_UIMover()' , width = ( Width_Height_Open[0]  ) )   
  289.     cmds.button( label = 'Mirror Selected Item' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'RigBox_MirrorGuide()' , width = ( Width_Height_Open[0]  ) )  
  290.     cmds.button( label = 'Freeze Guide Object' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'Rig_Box_FrzGrouperCtrls()' , width = ( Width_Height_Open[0]  ) )  
  291.     cmds.button( label = 'Add atrs Object' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = "RigBox_AddAllAtr( '' , 'Misc' , 'FK' , '_' , '_' )" , width = ( Width_Height_Open[0]  ) ) 
  292.  
  293.    
  294.    
  295.    
  296.     cmds.button( label = 'Aim Axis' , command = 'RigBox_AimAxis()' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Axis')  
  297.     cmds.optionMenu( 'Axis_follow_Win_OptMenu' , label=' Axis To Aim:' , parent = 'Rig_Box_MainCol_Axis')
  298.     for Axis in Axis_Channels:
  299.         cmds.menuItem( label = Axis )
  300.     cmds.checkBox( 'Axis_follow_Win_Check' , vis = True , v = True , label = '  Affect Last' , parent = 'Rig_Box_MainCol_Axis' , ann= 'Check this if you want the last selected item to match the oirentation of the 2nd to last selected item' )
  301.  
  302.  
  303.    
  304.    
  305.     ##rig building options
  306.     cmds.frameLayout( 'Rig_Box_ExtraOptsTab' , label = 'Extra Rig options' , vis = True , cll = True , cl = True , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
  307.     cmds.rowColumnLayout( 'Rig_Box_MainCol_Extras' , numberOfColumns = 1 ,  parent = 'Rig_Box_ExtraOptsTab' )      
  308.     cmds.checkBox( 'Rig_Box_Check_UnityScale' , vis = True , v = True , label = 'Unity Compatible scaling' , parent = 'Rig_Box_MainCol_Extras' , ann= 'Check this to enable unity scaling compatibility on the joints made.' )
  309.     cmds.checkBox( 'Rig_Box_Check_ReBuildJoints' , vis = True , v = True , label = 'Rebuild all joints' , parent = 'Rig_Box_MainCol_Extras' , ann= 'Check this for all joints to be remade.' )
  310.     cmds.checkBox( 'Rig_Box_Check_HideJoints' , vis = True , v = False , label = 'Show final joints' , cc = 'RigBox_HideFinalJoints()' , parent = 'Rig_Box_MainCol_Extras' , ann= 'Check this for all joints to be remade.' )
  311.  
  312.     cmds.button( label = 'CleanUpdate_Guides' , bgc = Bright_Red_Btn_Col , parent = 'Rig_Box_MainCol_Extras' , command = 'RigBox_UpdateOldGuides()' , width = ( Width_Height_Open[0]  ) )  
  313.     cmds.button( label = 'Remove All Atrs On selected' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Extras' , command = 'RigBox_RemoveAllAtrOnSel()' , width = ( Width_Height_Open[0]  ) )  
  314.  
  315.  
  316.    
  317.     cmds.rowColumnLayout( 'Rig_Box_MainCol_End' , numberOfColumns=2 ,  parent = 'Rig_Box_MainWin' )    
  318.  
  319.  
  320.    
  321.     cmds.button( label = 'Build Rig' , command = 'RigBox_Guide_To_Rig()' , width = ( Width_Height_Open[0]  ) , parent = 'Rig_Box_MainCol_End') 
  322.  
  323.  
  324.    
  325.     cmds.showWindow( 'Rig_Box_Win' )
  326.    
  327. Rig_Box_Win_cmd()  
  328.  
  329.  
  330. def RigBox_Build_BipedArm():
  331.     RigBox_SceneSize()
  332.     global Global_Scene_Size
  333.    
  334.     orig_Parent = RigBox_CurrentlySelected( True )
  335.    
  336.     cmds.select( clear = True )
  337.     for i in range( 0 , len( BipedArm_Naming ) ):
  338.         tmp_Xforms = BipedArm_Xforms[i]
  339.         Item = RigBox_Guide_Piece( BipedArm_Naming[i]  , 'Circle_Low'  )
  340.  
  341.         cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )    
  342.         cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )       
  343.         RigBox_AddAllAtr( Item[0] , 'Misc' , BipedArm_Opts[i] , BipedArm_Pins[i] , '_' )       
  344.        
  345. def RigBox_Build_BipedLeg():
  346.     RigBox_SceneSize()
  347.     global Global_Scene_Size
  348.    
  349.     orig_Parent = RigBox_CurrentlySelected( True )
  350.    
  351.     cmds.select( clear = True )
  352.     for i in range( 0 , len( BipedLeg_Naming ) ):
  353.         tmp_Xforms = BipedLeg_Xforms[i]
  354.         Item = RigBox_Guide_Piece( BipedLeg_Naming[i]  , 'Circle_Low'  )
  355.  
  356.         cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )    
  357.         cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )       
  358.         RigBox_AddAllAtr( Item[0] , 'Misc' , BipedLeg_Opts[i] , BipedLeg_Pins[i] , '_' )       
  359.    
  360. def RigBox_Build_BipedFKBack():
  361.     RigBox_SceneSize()
  362.     global Global_Scene_Size
  363.    
  364.     orig_Parent = RigBox_CurrentlySelected( True )
  365.    
  366.     cmds.select( clear = True )
  367.     for i in range( 0 , len( BipedFKBack_Naming ) ):
  368.         tmp_Xforms = BipedFKBack_Xforms[i]
  369.         Item = RigBox_Guide_Piece( BipedFKBack_Naming[i]  , 'Circle_Low'  )
  370.  
  371.         cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )    
  372.         cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )       
  373.         RigBox_AddAllAtr( Item[0] , 'Misc' , BipedFKBack_Opts[i] , BipedFKBack_Pins[i] , '_' )     
  374.        
  375.  
  376. def RigBox_SceneSize():
  377.     global Global_Scene_Size
  378.  
  379.     UnitFound = cmds.intSliderGrp( 'Rig_Box_UnitSize_Field' , q = True , v = True )
  380.    
  381.     CurrentSceneUnit = cmds.currentUnit( query=True, linear=True )
  382.  
  383.     if CurrentSceneUnit == 'mm':
  384.         UnitFound = ( UnitFound * 10 ) 
  385.    
  386.     if CurrentSceneUnit == 'cm':
  387.         UnitFound = UnitFound
  388.        
  389.     if CurrentSceneUnit == 'm':
  390.         UnitFound = ( UnitFound * .01 )
  391.        
  392.     print ( 'Unit Used / found is ' + str(UnitFound) )
  393.     Global_Scene_Size = UnitFound
  394.    
  395.    
  396. def RigBox_LocalConrolSize():
  397.     global Global_Local_Control_Size
  398.  
  399.     UnitFound = cmds.floatSliderGrp( 'Rig_Box_LocalControlSize_Field' , q = True , v = True )
  400.    
  401.     print ( 'Local Control size is: ' + str(UnitFound) )
  402.     Global_Local_Control_Size = UnitFound
  403.  
  404. def RigBox_HideFinalJoints():
  405.     global Joint_Grps_Vis
  406.    
  407.     tmp1 = cmds.checkBox( 'Rig_Box_Check_HideJoints' , q = True  , v = True )
  408.     Joint_Grps_Vis[0] =  tmp1
  409.     print ( 'changing visibility of final joints group. ' + str( tmp[0] ) )
  410.  
  411.    
  412. def Rig_Box_FrzGrouperCtrls():
  413.     Seled = RigBox_CurrentlySelected( True )
  414.     if Seled < 1:
  415.         print 'Please select an item to place in a group'
  416.     else:
  417.        
  418.         for x in Seled:
  419.             pass #check has children guide objects?
  420.             cmds.select( clear = True )
  421.             Test_Children = cmds.listRelatives( x , children = True  )
  422.             cmds.select( Test_Children )
  423.             ChildGuidesFound = RigBox_CurrentlySelected( True )
  424.                
  425.             if len( ChildGuidesFound ) < 1:
  426.                 pass #print ' no child guides found'           
  427.             else:
  428.                 print '\n child guides found, unparenting..'
  429.                 pass # is it a child of the world?
  430.                 cmds.select( clear = True )
  431.                 cmds.select( ChildGuidesFound )
  432.                 cmds.parent( world =True )
  433.                
  434.                
  435.             Newgroup = cmds.group( em=True, name=(x+"_TmpGrp"))
  436.             NewCons = cmds.parentConstraint( x , Newgroup , mo=False)
  437.             cmds.select( NewCons , r=True)
  438.             cmds.Delete();
  439.             cmds.select( clear=True )
  440.             cmds.select( x , r=True )
  441.             cmds.pickWalk( direction='up' )
  442.             xParent= cmds.ls( selection=True)  
  443.             cmds.parent(x, Newgroup)
  444.             cmds.select( clear = True)         
  445.             cmds.select( x , r = True) 
  446.             cmds.makeIdentity( apply=True, t=1, r=1, s=1, n=2 ) #all 0     
  447.             if xParent > 0:
  448.                 if xParent[0] == x:
  449.                     cmds.parent( x , world = True )
  450.                 else:
  451.                     cmds.parent( x , xParent ) 
  452.             else:
  453.                 pass
  454.             cmds.delete( Newgroup )
  455.  
  456.             # print ChildrenGuideFound
  457.             pass # reparent back up
  458.             if len( ChildGuidesFound ) < 1:
  459.                 pass               
  460.             else:
  461.                 for Child in ChildGuidesFound:
  462.                     cmds.parent( Child , x )       
  463.  
  464.    
  465. def RigBox_AimAxis(): #still needs tweaking to include an upvector of some kind!
  466.  
  467.     List_Sel = RigBox_CurrentlySelected( False )
  468.  
  469.     Axis_To_Use = cmds.optionMenu( 'Axis_follow_Win_OptMenu' ,q=True,  v=True )
  470.     Axis_Int = RigBox_List_To_Value( Axis_Channels , Axis_To_Use )
  471.  
  472.    
  473.     Aim_Ints = [ (1,0,0) , (0,1,0) , (0,0,1) , (-1,0,0) , (0,-1,0) , (0,0,-1) ]
  474.    
  475.     count = 0
  476.     while count < len(List_Sel):
  477.         if ( count + 1 ) < len(List_Sel):
  478.             aimCons = cmds.aimConstraint(  List_Sel[count+1] , List_Sel[count] , aim = Aim_Ints[Axis_Int] , mo = False )
  479.             cmds.delete( aimCons )
  480.         else:
  481.             AffectEnd = cmds.checkBox( 'Axis_follow_Win_Check' , q=True , v = True )
  482.             if AffectEnd is True:
  483.                 OrienCons = cmds.orientConstraint(  List_Sel[ count -1] , List_Sel[count] , mo = False )
  484.                 cmds.delete( OrienCons )
  485.         count+=1
  486.    
  487.    
  488. def RigBox_ColourMenuWin():
  489.     count = 1
  490.     while count < 31:
  491.         Colour = cmds.colorIndex(count, q=True)
  492.         cmds.button( label = '' , command = 'RigBox_ColourMenuChange(' + str(count) + ')' , h = 17 , bgc = Colour , width = 16 , parent = 'Rig_Box_MainCol_Colour')
  493.         count+=1
  494.  
  495. RigBox_ColourMenuWin()
  496.    
  497. def RigBox_ColourMenuChange( Colour )
  498.     global Global_Colour
  499.     Global_Colour = Colour
  500.  
  501.     List_Sel = RigBox_CurrentlySelected( False )
  502.     for x in List_Sel:
  503.         ShapesFound = cmds.listRelatives( shapes =True )
  504.         for Shapes in ShapesFound:
  505.             cmds.setAttr ( ( Shapes + '.overrideEnabled' ) , 1 )
  506.             cmds.setAttr ( ( Shapes + '.overrideColor' ) , Colour )
  507.     print ( 'Setting Colour to: ' +  str( Global_Colour ) )
  508.    
  509.    
  510. def RigBox_CurrentlySelected( CheckIfGuide ):   #returns selected + error msgs 
  511.     Selected= []
  512.     Selected = cmds.ls( selection=True , transforms = True )
  513.     if Selected is None:
  514.         return ''
  515.     else:
  516.         if CheckIfGuide is True:
  517.             GuidesOnly = []
  518.             for Possible_Guide in Selected:
  519.                 Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  Possible_Guide  , ex=True )
  520.                 if Test is True:
  521.                     GuidesOnly.append( Possible_Guide )
  522.                
  523.             if len(GuidesOnly) > 0:
  524.                 return GuidesOnly
  525.             else:
  526.                 return ''
  527.         else:
  528.             return Selected
  529.  
  530. def RigBox_LegalName( Name ):
  531.     tmp = cmds.ls( selection = True )
  532.     Name_Test_Group = cmds.group( em = True , name = Name )
  533.     Name_Test_Group2 = cmds.group( em = True , name = Name_Test_Group )
  534.     cmds.delete( Name_Test_Group  , Name_Test_Group2 )
  535.     Name = Name_Test_Group2
  536.  
  537.     if len( tmp ) < 1:
  538.         pass
  539.     else:
  540.         cmds.select( tmp )
  541.     return ( Name )    
  542.  
  543. def RigBox_MirrorGuide():
  544.     tmp = RigBox_CurrentlySelected( True )
  545.     for x in tmp:
  546.         cmds.select(clear=True)
  547.         NewJoint = cmds.joint ( n = ( x + '_Mirrored' ) )
  548.         tmp_cons = cmds.parentConstraint( x , NewJoint , mo = False )  
  549.         cmds.delete( tmp_cons )
  550.  
  551.         NewJointRightSide = cmds.mirrorJoint( NewJoint  , mirrorBehavior = True , myz = True , searchReplace = ( 'L_' , 'R_' ) )
  552.         cmds.delete( NewJoint )
  553.        
  554.         if "L_" in x:
  555.             Switch = [ 'L_' , 'R_' ]
  556.         if "Left_" in x:
  557.             Switch = [ 'Left_' , 'Right_' ]
  558.         if "R_" in x:
  559.             Switch = [ 'R_' , 'L_' ]
  560.         if "Right_" in x:
  561.             Switch = [ 'Right_' , 'Left_' ]
  562.            
  563.        
  564.         NewName_OtherSide = x.replace( Switch[0] , Switch[1] )
  565.         Item = cmds.duplicate( x , name = ( x.replace( Switch[0] , Switch[1] ) ) , rc = True , ic = False )
  566.        
  567.         cmds.select( Item[0] , hi =True )
  568.         cmds.select( Item[0] , d = True )
  569.        
  570.         GuideChildren = RigBox_CurrentlySelected( True )
  571.         print GuideChildren
  572.         if len( GuideChildren ) < 1:
  573.             pass
  574.         else:
  575.             cmds.delete( GuideChildren )
  576.        
  577.        
  578.         MirrorGrp = cmds.group( em = True )
  579.         cmds.parent( Item[0] , MirrorGrp )
  580.         cmds.scale(  -1, 1, 1 , MirrorGrp)
  581.  
  582.    
  583.         tmp_cons = cmds.pointConstraint( NewJointRightSide , Item[0] , mo = False )
  584.         cmds.delete( tmp_cons )
  585.         tmp_cons = cmds.orientConstraint( NewJointRightSide , Item[0] , mo = False )
  586.         cmds.delete( tmp_cons )
  587.         cmds.parent( Item[0] , NewJointRightSide )
  588.         cmds.select( clear = True )
  589.         cmds.select( Item[0] )
  590.         cmds.makeIdentity( apply = True, t=1, r=1, s=1, n=2 ) #all 0
  591.         cmds.parent( Item[0] , world = True  ) 
  592.         cmds.delete( NewJointRightSide )
  593.         cmds.delete( MirrorGrp )   
  594.        
  595.         Test = cmds.ls( ( x + '_Local_Jnt' ) , type = 'transform' )
  596.         if len( Test ) > 0:
  597.             cmds.select( clear = True )
  598.             cmds.select( Item[0] )
  599.             cmds.pickWalk( d = 'down' )
  600.             cmds.pickWalk( d = 'left' )
  601.             cmds.rename( ( NewName_OtherSide + '_Local_Jnt' ) )
  602.             Local_Rots = cmds.xform( ( x + '_Local_Jnt' ) , query = True , ro = True , os = True )     
  603.             cmds.xform( ( NewName_OtherSide + '_Local_Jnt' ) , ro = Local_Rots , os = True  )      
  604.        
  605.        
  606. def RigBox_DefaultGuideSetup_Start( Item ): # Create the Main Rig Guide Grp and continue! is ran each time a new guide piece is requested.
  607.     Group_Test = cmds.ls( 'Character_Rig_Guide' , type= 'transform' )
  608.     if len( Group_Test ) > 0:
  609.         pass
  610.     else: #exists
  611.         Create_Group = cmds.group( em=True , name= 'Character_Rig_Guide' )      #doesnt exhist, make it.
  612.         cmds.setAttr( ( 'Character_Rig_Guide' + '.v' ), 1 )
  613.         cmds.setAttr( ( 'Character_Rig_Guide' + '.inheritsTransform' ), 1 )
  614.     FindParent = cmds.listRelatives( Item , parent=True )
  615.     if FindParent is None:
  616.         cmds.parent( Item[0] , 'Character_Rig_Guide' )
  617.  
  618.  
  619. def RigBox_Guide_Circle_Low()
  620.     print 'Creating a Circle Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  621.     Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Circle_Low' )
  622.     RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
  623.  
  624. def RigBox_Guide_Circle_Hi():  
  625.     print 'Creating a Circle Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  626.     Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Circle_Hi' )
  627.     RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
  628.    
  629.    
  630. def RigBox_Guide_Ball():   
  631.     print 'Creating a Ball Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  632.     Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Misc' )
  633.     RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
  634.    
  635. def RigBox_Guide_Square()
  636.     print 'Creating a Square Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  637.     Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Square' )
  638.     RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
  639.    
  640.    
  641.    
  642. def RigBox_Guide_PoleV( type ):
  643.    
  644.     if type is 'Auto':
  645.         tmp = cmds.ls( selection = True , flatten = True)
  646.         if len( tmp ) < 1:
  647.             Item = RigBox_Guide_Piece( ( RigBox_LegalName('PoleV') ) , 'PoleV' )
  648.         else:
  649.             Item = RigBox_Guide_Piece( ( tmp[0] + '_Pole' ) , 'PoleV' )    
  650.        
  651.         RigBox_AddAllAtr( Item[0] , 'PoleV' , 'PoleV' , '_' , '_' )
  652.         return Item
  653.        
  654.     if type is 'Manual':
  655.         tmp = cmds.ls( selection = True , flatten = True)
  656.         if len( tmp ) < 2:
  657.             print 'Creating a PoleV Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  658.         else:
  659.             print 'Creating a PoleV Control.. between the selected items..'
  660.         World_Pos =  RigBox_IK_PolePosition( tmp )
  661.  
  662.         if len(tmp) < 1:
  663.             Item = RigBox_Guide_Piece( ( RigBox_LegalName('PoleV') ) , 'PoleV' )
  664.         if len(tmp) > 0:
  665.             cmds.select( clear = True )
  666.             cmds.select( tmp[0] )
  667.             Item = RigBox_Guide_Piece( ( tmp[0] + '_Pole' ) , 'PoleV' )    
  668.        
  669.        
  670.         RigBox_AddAllAtr( Item[0] , 'PoleV' , 'PoleV' , '_' , '_' )
  671.         cmds.move( World_Pos[0] , World_Pos[1] , World_Pos[2] , Item )
  672.  
  673.         return Item
  674.  
  675. # def RigBox_Guide_IKFK(): 
  676.     # print 'Creating a IK-FK Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
  677.     # Item = RigBox_Guide_Piece( ( RigBox_LegalName('IKFK') ) , 'IKFK' )
  678.     # RigBox_AddAllAtr( Item[0] , 'IKFK' , '_' , '_' , '_' )
  679.     # return Item  
  680.    
  681. def RigBox_Guide_Hip():
  682.     print 'wip'
  683.  
  684.     def RigBox_Guide_Prop():
  685.         print 'wip'
  686.  
  687.     def RigBox_Guide_Back():
  688.         print 'wip'
  689.  
  690.     def RigBox_Guide_Clav():
  691.         print 'wip'
  692.  
  693.     def RigBox_Guide_Arm():
  694.         print 'wip'
  695.  
  696.     def RigBox_Guide_Hand():
  697.         print 'wip'
  698.  
  699.     def RigBox_Guide_Head():
  700.         print 'wip'
  701.  
  702.     def RigBox_Guide_EyeAim():
  703.         print 'wip'
  704.  
  705.     def RigBox_Guide_Leg():
  706.         print 'wip'
  707.  
  708.     def RigBox_Guide_Foot():
  709.         print 'wip'
  710.    
  711.     def RigBox_Guide_Main():   
  712.         print 'wip'
  713.         print 'Creating a Main Control.. Move scale and rotate to where it needs to be and place guide items as its children'
  714.         Item = RigBox_Guide_Piece( 'Character' , 'Main' )
  715.         RigBox_AddAllAtr( Item , 'Main' , 6 , 1 , 0 )
  716.  
  717.         FindParent = cmds.listRelatives( Item , parent=True )
  718.         if FindParent is None:
  719.             pass
  720.         else:
  721.             cmds.parent( Item , world = True )
  722.         cmds.move( 0 , 0 , 0 , Item )
  723.         print Item
  724.         GrabAllGuidesMade = RigBox_FindAll( 'Guide' )
  725.         for x in GrabAllGuidesMade:
  726.             if x == Item[0]:
  727.                 print ( 'Ignoring ' + x )
  728.             else:
  729.                 FindParent = cmds.listRelatives( x , parent=True )
  730.                 if FindParent is None:
  731.                     print x
  732.                     print FindParent
  733.                     cmds.parent( x , Item )
  734.                 else:
  735.                     pass   
  736.  
  737.    
  738.    
  739. pass #Attribute setting reading etc go here..
  740.    
  741.    
  742. def RigBox_List_To_Value( List , ToFind )# given a list to check, it spits back a number that matches
  743.     pass # convert string to list
  744.     Check_List_Is_String = isinstance( List , str)
  745.  
  746.     if Check_List_Is_String is True:
  747.         print 'STRING DETECTED INSTEAD OF LIST, converting'
  748.         Tmp_List = List.split( Split_Char )
  749.         List = []
  750.         List = List
  751.     else:
  752.         pass
  753.    
  754.     count = 0
  755.     while count < len( List ):
  756.         List_Item = List[ count ]
  757.         Match_Test = ToFind == List_Item #may be a dodgy change from is to ==???
  758.         if Match_Test is True:
  759.             return count
  760.         else:
  761.             pass
  762.         count+=1
  763.    
  764.    
  765.    
  766. def RigBox_AddAllAtr( Item , Controller_Vis_Type , Sys_Type , Pin_Type , Extra_Type ): #feed me the guide item to add the setup attrs.. . all as strings
  767.  
  768.     if Item == '':
  769.          
  770.         tmp = cmds.ls( selection=True , transforms = True )
  771.         Item = tmp[0]
  772.         print 'item false'
  773.     else:
  774.         pass
  775.  
  776.     cmds.addAttr(  Item , shortName = ( 'RigBox_Guide_ControlType' ) , dt = "string"  ) #add it to node
  777.     cmds.setAttr( (  Item  + '.' + 'RigBox_Guide_ControlType' ) , str( Controller_Vis_Type ) , type = "string" )
  778.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_ControlType' ) , channelBox =True , keyable= True ) #add it to node
  779.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_ControlType' ) , keyable = True ) #add it to node
  780.  
  781.     System_Types_Flat = Split_Char.join( System_Types )
  782.  
  783.     cmds.addAttr(  Item , shortName = ( 'RigBox_Guide_SystemType' ) , at = 'enum' , en = System_Types_Flat ) #add it to node
  784.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_SystemType' ) , ( RigBox_List_To_Value( System_Types , Sys_Type ) ) ) #set the correct value
  785.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_SystemType' ) , channelBox =True , keyable= True ) #add it to node
  786.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_SystemType' ) , keyable = True ) #add it to node 
  787.  
  788.     Pin_Types_Flat = Split_Char.join( Pin_Types )
  789.  
  790.     cmds.addAttr(  Item , shortName = ( 'RigBox_Guide_PinType' ) , at = 'enum' , en = Pin_Types_Flat ) #add it to node
  791.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_PinType' ) , ( RigBox_List_To_Value( Pin_Types , Pin_Type ) ) ) #set the correct value
  792.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_PinType' ) , channelBox =True , keyable= True ) #add it to node
  793.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_PinType' ) , keyable = True ) #add it to node
  794.  
  795.     Extra_Types_Flat = Split_Char.join( Extra_Types )
  796.  
  797.     cmds.addAttr(  Item , shortName = ( 'RigBox_Guide_ExtraType' ) , at = 'enum' , en = Extra_Types_Flat ) #add it to node
  798.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_ExtraType' ) , ( RigBox_List_To_Value( Extra_Types , Extra_Type ) ) ) #set the correct value
  799.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_ExtraType' ) , channelBox =True , keyable= True ) #add it to node
  800.     cmds.setAttr(  (  Item  + '.' + 'RigBox_Guide_ExtraType' ) , keyable = True ) #add it to node  
  801.  
  802.     for opts in Extra_Options:
  803.         Extra_Opts_Flat_Vals = Split_Char.join( Extra_Options_Values )
  804.         cmds.addAttr(  Item , shortName = ( opts ) , at = 'enum' , en = Extra_Opts_Flat_Vals ) #add it to node 
  805.         cmds.setAttr(  (  Item  + '.' + opts ) , ( RigBox_List_To_Value( Extra_Options_Values , Extra_Options_Values[1] ) ) ) #set the correct value
  806.         cmds.setAttr(  (  Item  + '.' + opts ) , channelBox =True , keyable= True ) #add it to node
  807.         cmds.setAttr(  (  Item  + '.' + opts ) , keyable = True ) #add it to node  
  808.    
  809.  
  810. def RigBox_UpdateOldGuides(): # used to update guides done with older version of this script..
  811.     All = RigBox_FindAll( 'Guide' )
  812.     for x in All:
  813.         sysType = RigBox_ReadSystemTypeAtr( x )
  814.         pinType = RigBox_ReadPinTypeAtr( x )
  815.         extraType = RigBox_ReadExtraTypeAtr( x )
  816.         RigBox_RemoveAllAtr( x )
  817.         RigBox_AddAllAtr( x , 'Misc' , sysType , pinType , extraType )
  818.  
  819. def RigBox_RemoveAllAtrOnSel():
  820.     AllSel = cmds.ls( selection = True )
  821.     for x in AllSel:
  822.         RigBox_RemoveAllAtr( x )
  823.    
  824. def RigBox_RemoveAllAtr( Item ): #feed me the item to cleanup ..
  825.  
  826.     AllAtrs = [ 'RigBox_Guide_ControlType' , 'RigBox_Guide_SystemType' , 'RigBox_Guide_PinType' , 'RigBox_Guide_ExtraType' , 'IF_IK_allow_Breakable_IK_Setup' , 'IF_IK_allow_IK_Stretch_Opt' , 'Follow' ]
  827.    
  828.     for Atrs in AllAtrs:
  829.  
  830.         Test = cmds.attributeQuery( Atrs , node =  Item  , ex=True )
  831.         if Test is True:
  832.             cmds.deleteAttr(  ( Item + '.' + Atrs ) ) #add it to node
  833.  
  834.        
  835. def RigBox_ReadControlTypeAtr( Item ): #feed me the guide item to get .. returns string.
  836.     Exist = cmds.ls( Item )
  837.     if len(Exist) < 1 :
  838.         pass
  839.     else:
  840.         Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  Item  , ex=True )
  841.         if Test is True:
  842.             TypeFound = cmds.getAttr(  ( Item + '.RigBox_Guide_ControlType' ) )
  843.             return TypeFound # will be string
  844.  
  845. def RigBox_ReadSystemTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
  846.     Exist = cmds.ls( Item )
  847.     if len(Exist) < 1 :
  848.         pass
  849.     else:
  850.         Test = cmds.attributeQuery( 'RigBox_Guide_SystemType' , node =  Item  , ex=True )
  851.         if Test is True:
  852.             SystemTypeFound = cmds.getAttr(  ( Item + '.RigBox_Guide_SystemType' ) ) # will return int
  853.             return System_Types[ SystemTypeFound ] 
  854.    
  855. def RigBox_ReadPinTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
  856.     Exist = cmds.ls( Item )
  857.     if len(Exist) < 1 :
  858.         pass
  859.     else:
  860.         Test = cmds.attributeQuery( 'RigBox_Guide_PinType' , node =  Item  , ex=True )
  861.         if Test is True:
  862.             PinTypeFound = cmds.getAttr(  ( Item + '.RigBox_Guide_PinType' ) ) # will return int
  863.             return Pin_Types[ PinTypeFound ]       
  864.    
  865. def RigBox_ReadExtraTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
  866.     Exist = cmds.ls( Item )
  867.     if len(Exist) < 1 :
  868.         pass
  869.     else:
  870.         Test = cmds.attributeQuery( 'RigBox_Guide_ExtraType' , node =  Item  , ex=True )
  871.         if Test is True:
  872.             ExtraTypeFound = cmds.getAttr(  ( Item + '.RigBox_Guide_ExtraType' ) )  # will return int
  873.             return Extra_Types[ ExtraTypeFound ]   
  874.    
  875. pass #Attribute setting reading etc go here.. all will feed back strings.
  876.    
  877. def RigBox_Guide_Piece( GuidePieceName , GuidePieceType ): #all the common types of guide controls to be made go here..
  878.    
  879.     global Global_Scene_Size
  880.     global Global_Colour
  881.    
  882.    
  883.  
  884.  
  885.    
  886.    
  887.    
  888.     MakeSureNameIsString = isinstance( GuidePieceName , str)   
  889.     if MakeSureNameIsString is True:
  890.         pass
  891.     else:
  892.         GuidePieceName = ''.join(GuidePieceName)       
  893.    
  894.     CurrentlySelected = RigBox_CurrentlySelected( 'True' )
  895.  
  896.     CreateLocal = True 
  897.        
  898.  
  899.     if GuidePieceType is 'Misc':
  900.         tmp =cmds.circle( n = GuidePieceName , nr = ( 0 , 1 , 0 ) , r= ( Global_Scene_Size * 1) , d=3 , ch=False ) #in with the new!
  901.         tmp2 = cmds.duplicate( tmp , rc = True , ic = False )
  902.         cmds.rotate( 90 , 0 , 0 , tmp2 , r = True )
  903.         tmp3 = cmds.duplicate( tmp , rc = True , ic = False )
  904.         cmds.rotate( 0 , 0 , 90 , tmp3 , r = True )
  905.         cmds.select( tmp2 , tmp3 )
  906.         cmds.makeIdentity( apply=True, t=1, r=1, s=1, n=2 )
  907.         cmds.select( hi = True )
  908.         tmp_shapes = cmds.ls( selection = True , shapes=True )
  909.         tmp_trans = cmds.ls( selection = True , transforms=True )
  910.         cmds.select( clear=True )
  911.         cmds.parent( tmp_shapes , tmp , r = True , s = True )
  912.         cmds.delete( tmp_trans )       
  913.  
  914.        
  915.        
  916.     if GuidePieceType is 'Main':
  917.         tmp = cmds.circle( n = GuidePieceName , nr = ( 0 , 1 , 0 ) , r= ( Global_Scene_Size * 7) ,d=3,ch=False) #in with the new!
  918.         cmds.select( clear=True )
  919.         cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
  920.         cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
  921.         cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )        
  922.         cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )        
  923.         cmds.scale( 1.415  , r=True , ocp=True )
  924.         cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
  925.         cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
  926.         cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )        
  927.         cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )                    
  928.         cmds.scale( 1,1,1.415  , r=True , ocp=True )
  929.         CreateLocal = False
  930.        
  931.        
  932.         pass # cmds.sphere( -ch on -o on -po 0 -ax 0 1 0 -r 27.706748 -nsp 4 ;
  933.         pass # disconnectAttr |nurbsSphere1|nurbsSphereShape1.instObjGroups[0] initialShadingGroup.dagSetMembers[1];
  934.         pass # cmds.sphere( r= Unit ) #knee object         
  935.        
  936.     if GuidePieceType is 'PoleV':
  937.         tmp = cmds.sphere( name = GuidePieceName  , r = ( Global_Scene_Size * .4 ) ) #knee object      
  938.         shape = cmds.listRelatives( tmp[0] , children = True , shapes = True )
  939.         shadingGroup = cmds.listConnections( tmp[0] + '.instObjGroups')
  940.         shadingGroup = cmds.listConnections( shape[0] + '.instObjGroups')
  941.         # cmds.disconnectAttr( ( shape[0] + '.instObjGroups[0]' ) , ( shadingGroup[0] + '.dagSetMembers[0]'  ) )
  942.         CreateLocal = False
  943.  
  944.        
  945.     if GuidePieceType is 'IKFK':
  946.         tmp = cmds.sphere( name = GuidePieceName  , r = ( Global_Scene_Size * .4 ) ) #knee object      
  947.         shape = cmds.listRelatives( tmp[0] , children = True , shapes = True )
  948.         shadingGroup = cmds.listConnections( tmp[0] + '.instObjGroups')
  949.         shadingGroup = cmds.listConnections( shape[0] + '.instObjGroups')
  950.         # cmds.disconnectAttr( ( shape[0] + '.instObjGroups[0]' ) , ( shadingGroup[0] + '.dagSetMembers[0]'  ) )
  951.         RigBox_AddAllAtr( tmp[0] , 'IKFK' , '_' , '_' , '_' )
  952.         cmds.addAttr(  tmp , shortName = ( 'FK_IK_Switch' ) , attributeType='float' , min = 0.0 , max=1.0 )
  953.         cmds.setAttr(  (  tmp[0]  + '.' + 'FK_IK_Switch' ) , channelBox =True , keyable= True ) #add it to node
  954.         cmds.setAttr(  (  tmp[0]  + '.' + 'FK_IK_Switch' ) , keyable = True ) #add it to node  
  955.  
  956.         cmds.addAttr(  tmp , shortName = ( 'FK_IK_TwistOveride' ) , attributeType='float' )
  957.         cmds.setAttr(  (  tmp[0]  + '.' + 'FK_IK_TwistOveride' ) , channelBox =True , keyable= True ) #add it to node
  958.         cmds.setAttr(  (  tmp[0]  + '.' + 'FK_IK_TwistOveride' ) , keyable = True ) #add it to node        
  959.        
  960.        
  961.        
  962.         CreateLocal = False
  963.        
  964.        
  965.        
  966.     if GuidePieceType is 'Circle_Low':     
  967.         tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 1 , ch = False ) #in with the new!
  968.  
  969.     if GuidePieceType is 'Circle_Hi':      
  970.         tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 3 , ch = False ) #in with the new!
  971.        
  972.        
  973.            
  974.     if GuidePieceType is 'Square':     
  975.         tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 3 , ch = False ) #in with the new!
  976.         cmds.select( clear=True )
  977.         cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
  978.         cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
  979.         cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )        
  980.         cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )        
  981.         cmds.scale( 1.415  , r=True , ocp=True )
  982.         cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
  983.         cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
  984.         cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )        
  985.         cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )                    
  986.         cmds.scale( 1,1,1.415  , r=True , ocp=True )       
  987.        
  988.        
  989.  
  990.        
  991.     if GuidePieceType is 'Twist':
  992.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  993.        
  994.        
  995.        
  996.     if GuidePieceType is 'Hip':
  997.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  998.  
  999.     if GuidePieceType is 'Prop':
  1000.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1001.        
  1002.        
  1003.     if GuidePieceType is 'Spine':
  1004.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1005.  
  1006.     if GuidePieceType is 'Chest':
  1007.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1008.  
  1009.  
  1010.        
  1011.     if GuidePieceType is 'Head':
  1012.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1013.  
  1014.     if GuidePieceType is 'Jaw':
  1015.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1016.  
  1017.     if GuidePieceType is 'Ear':
  1018.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1019.        
  1020.     if GuidePieceType is 'Nose':
  1021.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1022.  
  1023.     if GuidePieceType is 'Eyelid':
  1024.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1025.        
  1026.     if GuidePieceType is 'Cheek':
  1027.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1028.        
  1029.     if GuidePieceType is 'Mouth':
  1030.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1031.        
  1032.     if GuidePieceType is 'EyeBrow':
  1033.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1034.  
  1035.        
  1036.     if GuidePieceType is 'EyeAim':
  1037.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1038.        
  1039.  
  1040.  
  1041.        
  1042.     if GuidePieceType is 'Clav':
  1043.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1044.  
  1045.     if GuidePieceType is 'Shoulder':
  1046.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1047.  
  1048.     if GuidePieceType is 'Elbow':
  1049.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1050.        
  1051.        
  1052.        
  1053.     if GuidePieceType is 'Hand':
  1054.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1055.  
  1056.     if GuidePieceType is 'Finger':
  1057.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1058.  
  1059.        
  1060.     if GuidePieceType is 'Thigh':
  1061.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1062.  
  1063.     if GuidePieceType is 'Knee':
  1064.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1065.        
  1066.     if GuidePieceType is 'Ankle':
  1067.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1068.  
  1069.     if GuidePieceType is 'FootRoll':
  1070.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1071.  
  1072.     if GuidePieceType is 'Toe':
  1073.         tmp = cmds.sphere( name = GuidePieceName  , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object       
  1074.  
  1075.     # else:
  1076.         # print 'type not understood or exists for Guide Piece..'
  1077.         # tmp = ''     
  1078.        
  1079.     if CreateLocal is True:
  1080.         pass #create the local point for the object asked..
  1081.         tmp_local = cmds.spaceLocator( n = ( GuidePieceName + '_Local_Jnt' ) )
  1082.         cmds.parent( tmp_local , tmp )
  1083.         cmds.rotate( 0 , 0 , 0 , tmp_local , a = True )
  1084.         cmds.move( 0 , 0 , 0 , tmp_local , ls = True )
  1085.        
  1086.         Channels = [ 'X' , 'Y' , 'Z' ]
  1087.         CurrentSceneUnit = cmds.currentUnit( query=True , linear=True )    
  1088.         if CurrentSceneUnit == 'mm':
  1089.             UnitFound =  1000
  1090.        
  1091.         if CurrentSceneUnit == 'cm':
  1092.             UnitFound =  10
  1093.            
  1094.         if CurrentSceneUnit == 'm':
  1095.             UnitFound =  0.001
  1096.        
  1097.         for chan in Channels:
  1098.            
  1099.             cmds.setAttr(  (  tmp_local[0]  + '.' + 'localScale' + chan ) , UnitFound ) #add it to node
  1100.        
  1101.        
  1102.    
  1103.  
  1104.  
  1105.  
  1106.     RigBox_DefaultGuideSetup_Start( tmp )
  1107.     cmds.select( clear = True )
  1108.     cmds.select( GuidePieceName )
  1109.     RigBox_ColourMenuChange( Global_Colour )
  1110.     cmds.select( clear = True   )  
  1111.    
  1112.    
  1113.    
  1114.    
  1115.    
  1116.     pass #parenting stage, check if initial selected item was a guide piece, if so parent underneath, no exceptions.
  1117.     if len(CurrentlySelected) < 1:
  1118.         pass
  1119.     else:
  1120.         cmds.parent( tmp , CurrentlySelected )
  1121.         cmds.xform(  tmp , t = (0,0,0) , ro = (0, 0, 0) , a = True )
  1122.        
  1123.        
  1124.        
  1125.     cmds.select( tmp )
  1126.     return tmp     
  1127.  
  1128.    
  1129. def RigBox_FindAll( type ): #run this to find every item in the scene created by the guide system.
  1130.     global All_Controls_Made
  1131.    
  1132.    
  1133.    
  1134.     AllScene = cmds.ls()
  1135.     All = []
  1136.  
  1137.     for x in AllScene:
  1138.         Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  x  , ex=True )
  1139.         if Test is True:
  1140.             All.append( x )
  1141.         else:
  1142.             pass       
  1143.  
  1144.     if type is 'Joint':
  1145.         tmp = cmds.ls( ( '*' + Suffix_Joints[0] ) , type = 'joint' )   
  1146.         All = []       
  1147.         for x in tmp:
  1148.             Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  x  , ex=True )
  1149.             if Test is True:
  1150.                 All.append( x )
  1151.             else:
  1152.                 pass   
  1153.    
  1154.     if type is 'Joint_FK':
  1155.         tmp = cmds.ls( ( '*' + Suffix_Joints[2] ) , type = 'joint' )   
  1156.         All = []       
  1157.         for x in tmp:
  1158.             Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  x  , ex=True )
  1159.             if Test is True:
  1160.                 All.append( x )
  1161.             else:
  1162.                 pass           
  1163.                
  1164.     if type is 'Joint_IK':
  1165.         tmp = cmds.ls( ( '*' + Suffix_Joints[1] ) , type = 'joint' )   
  1166.         All = []
  1167.         for x in tmp:
  1168.             Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  x  , ex=True )
  1169.             if Test is True:
  1170.                 All.append( x )
  1171.             else:
  1172.                 pass       
  1173.    
  1174.     if type is 'Joint_IK_Extra':
  1175.         tmp = cmds.ls( ( '*' + Suffix_Joints[3] ) , type = 'joint' )   
  1176.         All = []
  1177.         for x in tmp:
  1178.             Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  x  , ex=True )
  1179.             if Test is True:
  1180.                 All.append( x )
  1181.             else:
  1182.                 pass   
  1183.    
  1184.    
  1185.     if type is 'Guide':
  1186.         cmds.select( clear = True )
  1187.         cmds.select( All )
  1188.         tmp = cmds.ls( selection = True , type = 'joint' )     
  1189.         cmds.select( clear = True )
  1190.         cmds.select( All )
  1191.         if len(tmp) < 1:
  1192.             pass
  1193.         else:
  1194.             cmds.select( tmp , d = True )
  1195.         All = cmds.ls( selection = True , type = 'transform' )
  1196.     else:
  1197.         pass
  1198.  
  1199.     cmds.select( clear = True )
  1200.        
  1201.     print ( '\n Found ' + str(len(All)) + '  ' + str(type) + ' items in Maya scene. \n')
  1202.     return All
  1203.  
  1204. def RigBox_FindAncestor( Items ): # returns the grandfather items
  1205.     FinalAncestors = []
  1206.     tmp_list = set( Items )
  1207.     for Item in set( Items ):  
  1208.         ChildrenOfItems = cmds.listRelatives( Item, c = True , type = 'transform' )
  1209.         if ChildrenOfItems is None:
  1210.             pass #broken deadend ignore
  1211.         else:
  1212.             for child in ChildrenOfItems:
  1213.                 if child in tmp_list:
  1214.                     tmp_list.remove( child )
  1215.                 else:
  1216.                     pass
  1217.                    
  1218.     for x in tmp_list:
  1219.         FinalAncestors.append( x ) 
  1220.     return FinalAncestors
  1221.    
  1222. def In_List_Test( Item , List ):
  1223.     for x in List:
  1224.         Test_Length = len( str(x) ) == len( str(Item) )
  1225.         if Test_Length is True:
  1226.             Test_StringMatch = str(x) == str(Item)
  1227.             if Test_StringMatch is True:
  1228.                 print 'found'
  1229.                 print x
  1230.                 return True
  1231.                 break
  1232.                 pass # print ( 'match = ' + x + '  :goes with:  ' + Item )             
  1233.  
  1234. pass # real meat of the rigging begins from here on.. all above are UI and incidentals.
  1235.  
  1236. def RigBox_GrouperCtrls( x ): #pass the name, type of allowed movement on final, final name is returned and group above.
  1237.     Newgroup = cmds.group( em = True , name = ( x.replace( '_Grp' , '' ) + '_Grp' ) )
  1238.     NewCons = cmds.parentConstraint( x , Newgroup , mo = False )
  1239.     cmds.select( NewCons , r = True )
  1240.     cmds.Delete()
  1241.     cmds.select( clear = True )
  1242.     cmds.select( x , r = True )
  1243.     cmds.pickWalk( direction = 'up' )
  1244.     xParent= cmds.ls( selection = True)
  1245.     cmds.parent( x , Newgroup )
  1246.     if xParent > 0:
  1247.         if xParent[0] == x:
  1248.             pass #no parent..
  1249.         else:
  1250.             cmds.parent( Newgroup , xParent ) #has parent..
  1251.     else:
  1252.         pass
  1253.     cmds.makeIdentity( x , apply = True , t = 1 , r = 1 , s = 1 )
  1254.  
  1255.  
  1256. def RigBox_Blend_3_Items( Item , Item_Goal_1 , Item_Goal_2 , type , Mo_Offset ):     #IK FK Blends the last 2 items to the first   
  1257.     pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################     
  1258.     Test_Atr_Exist = cmds.attributeQuery( IK_FK_Blend_Atr[0] , node =  Item  , ex=True )
  1259.     if Test_Atr_Exist is True:
  1260.         pass
  1261.     else:
  1262.         cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[0] , attributeType = 'float' , min = 0.0 , max = 1.0 )
  1263.         cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[1] , attributeType = 'float' , min = 0.0 , max = 1.0 )
  1264.  
  1265.         cmds.setAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , lock = False , channelBox = True )
  1266.         cmds.setAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , keyable = True )
  1267.  
  1268.     Reverse_Node = cmds.shadingNode( 'reverse' , asUtility=True , n= ( Item + '_Rev_Node' ) )  
  1269.     cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Reverse_Node + '.inputX' ) )     
  1270.     cmds.connectAttr( ( Reverse_Node + '.outputX' ) , ( Item + '.' + IK_FK_Blend_Atr[1] ) )    
  1271.    
  1272.        
  1273.     if type is 'UseCons':
  1274.    
  1275.         cmds.parentConstraint( Item_Goal_1 , Item , mo = Mo_Offset )
  1276.         cmds.parentConstraint( Item_Goal_2 , Item , mo = Mo_Offset )
  1277.        
  1278.         Cons_Name = cmds.parentConstraint( Item , query=True ) 
  1279.         Cons_Targets = cmds.parentConstraint( Item , query=True , tl=True )        
  1280.        
  1281.         cmds.setAttr( ( Cons_Name + '.' + 'interpType' ) , 1)
  1282.        
  1283.         # setAttr "Misc11_Jnt_parentConstraint1.interpType" 0;
  1284.        
  1285.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )             
  1286.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' )   )                   
  1287.  
  1288.         Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )     
  1289.         cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Scale_Blend_Node + '.color2' ) )
  1290.         cmds.connectAttr( ( Item_Goal_2 + '.scale' ) , ( Scale_Blend_Node + '.color1' ) )  
  1291.         cmds.connectAttr( ( Scale_Blend_Node + '.output' ) , ( Item + '.scale' ) )             
  1292.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Scale_Blend_Node + '.blender' ) )        
  1293.        
  1294.        
  1295.        
  1296.     if type is 'UseBlends':
  1297.         print ( 'blending on .. \n' + Item + '\n with both ' + Item_Goal_1 + ' \ ' + Item_Goal_2 )
  1298.         Trans_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Tran_Blend_Node' ) )      
  1299.         cmds.connectAttr( ( Item_Goal_1 + '.translate' ) , ( Trans_Blend_Node + '.color2' ) )
  1300.         cmds.connectAttr( ( Item_Goal_2 + '.translate' ) , ( Trans_Blend_Node + '.color1' ) )  
  1301.         cmds.connectAttr( ( Trans_Blend_Node + '.output' ) , ( Item + '.translate' ) )             
  1302.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Trans_Blend_Node + '.blender' ) )        
  1303.  
  1304.  
  1305.         Rots_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Rot_Blend_Node' ) )    
  1306.         cmds.connectAttr( ( Item_Goal_1 + '.rotate' ) , ( Rots_Blend_Node + '.color2' ) )
  1307.         cmds.connectAttr( ( Item_Goal_2 + '.rotate' ) , ( Rots_Blend_Node + '.color1' ) )  
  1308.         cmds.connectAttr( ( Rots_Blend_Node + '.output' ) , ( Item + '.rotate' ) )             
  1309.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Rots_Blend_Node + '.blender' ) )         
  1310.  
  1311.  
  1312.         Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )     
  1313.         cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Scale_Blend_Node + '.color2' ) )
  1314.         cmds.connectAttr( ( Item_Goal_2 + '.scale' ) , ( Scale_Blend_Node + '.color1' ) )  
  1315.         cmds.connectAttr( ( Scale_Blend_Node + '.output' ) , ( Item + '.scale' ) )             
  1316.         cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Scale_Blend_Node + '.blender' ) )        
  1317.         pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################     
  1318.  
  1319.  
  1320. def RigBox_Blend_2_Items( Item , Item_Goal_1 , type , Mo_Offset ):   #Blends the first item to the other directly.
  1321.     pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################     
  1322.     Test_Atr_Exist = cmds.attributeQuery( IK_FK_Blend_Atr[0] , node =  Item  , ex=True )
  1323.     if Test_Atr_Exist is True:
  1324.         pass
  1325.     else:
  1326.         cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[0] , attributeType = 'float' , min = 0.0 , max = 1.0 )
  1327.         cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[1] , attributeType = 'float' , min = 0.0 , max = 1.0 )
  1328.        
  1329.     if type is 'UseCons':
  1330.    
  1331.         cmds.parentConstraint( Item_Goal_1 , Item , mo = Mo_Offset )   
  1332.         Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )     
  1333.         cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Item + '.scale' ) )
  1334.  
  1335.        
  1336.     if type is 'UseBlends':
  1337.         cmds.connectAttr( ( Item_Goal_1 + '.translate' ) , ( Item + '.translate' ) )
  1338.         cmds.connectAttr( ( Item_Goal_1 + '.rotate' ) , ( Item + '.rotate' ) )
  1339.         cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Item + '.scale' ) )
  1340.     pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################     
  1341.    
  1342.    
  1343. def RigBox_RigGrpCleanup(): # removes all the ik fk groups and any others its known, process is ran before joint creation etc.
  1344.     pass # need to remove all the old character rig controls if found?
  1345.  
  1346.     TestRebuild = cmds.checkBox( 'Rig_Box_Check_ReBuildJoints' , q = True , v = True ) 
  1347.     AllGrps_MinusGuide = RigBox_All_Grps[1:]
  1348.     for Grp in AllGrps_MinusGuide:
  1349.         TestExist = cmds.ls( Grp )
  1350.        
  1351.         if len( TestExist ) < 1:
  1352.             pass
  1353.         else:
  1354.            
  1355.             if Grp is Joint_Grps[0]:
  1356.                 if TestRebuild is False:
  1357.                     pass
  1358.                 else:
  1359.                     cmds.delete( Grp ) 
  1360.             else:
  1361.                 cmds.delete( Grp )             
  1362.  
  1363.            
  1364. def RigBox_RigGrpCreate()# create all groups before working.
  1365.     pass # need to remove all the old character rig controls if found?
  1366.    
  1367.    
  1368.     TestMain = cmds.ls( MainGrp )
  1369.     if len( TestMain ) < 1:
  1370.         cmds.group( em = True , name = MainGrp )        #doesnt exhist, make it.
  1371.         cmds.parent( RigBox_All_Grps[0] , MainGrp )
  1372.  
  1373.     AllGrps_MinusGuide = RigBox_All_Grps
  1374.     AllGrps_MinusGuide_Vis = RigBox_All_Grps_Vis
  1375.     AllGrps_MinusGuide_InheritTransform = RigBox_All_Grps_InheritTransform 
  1376.  
  1377.    
  1378.    
  1379.     count = 0
  1380.     for Grp in AllGrps_MinusGuide:
  1381.         TestExist = cmds.ls( Grp , type= 'transform' )
  1382.         if len( TestExist ) < 1:
  1383.             Controls_Group = cmds.group( em = True , name = Grp , parent = MainGrp )        #doesnt exhist, make it.
  1384.             cmds.setAttr( ( Grp + '.v' ) , AllGrps_MinusGuide_Vis[ count ] )   
  1385.             cmds.setAttr( ( Grp + '.inheritsTransform' ) , AllGrps_MinusGuide_InheritTransform[ count ] )  
  1386.  
  1387.         count+=1   
  1388.  
  1389.     #set vis of group guide to 0
  1390.     cmds.setAttr( ( RigBox_All_Grps[0] + '.v' ) , 0 )
  1391.  
  1392.     #set vis of character joints
  1393.     Check_Vis = cmds.checkBox( 'Rig_Box_Check_HideJoints' , q = True  , v = True )
  1394.     cmds.setAttr( ( Joint_Grps[0] + '.v' ) , Check_Vis )
  1395.    
  1396.     grpParent = cmds.listRelatives( RigBox_All_Grps[0] , parent=True ) 
  1397.     if grpParent is None: #has no parent           
  1398.         cmds.parent( RigBox_All_Grps[0] , MainGrp )
  1399.     else:
  1400.         if len(grpParent) > 0: #has no parent  
  1401.             print grpParent
  1402.             Test = grpParent[0] == MainGrp
  1403.             print Test
  1404.             if Test is False:
  1405.                 cmds.parent( RigBox_All_Grps[0] , MainGrp )    
  1406.            
  1407.        
  1408.        
  1409.        
  1410. def RigBox_JointChainCreator():     #   Creates all the Joints FK and IK and blending / scale.
  1411.  
  1412.     pass #create the joints system for ik fk etc!      
  1413.     AllItemGuides = RigBox_FindAll( 'Guide' )
  1414.     All_To_Be_Made = []
  1415.     for x in AllItemGuides: #create all the joints in correct position of world.
  1416.         Test_Is_Joint_Wanted = RigBox_ReadSystemTypeAtr( x )
  1417.         if Test_Is_Joint_Wanted is 'IK':
  1418.             All_To_Be_Made.append( x )     
  1419.         if Test_Is_Joint_Wanted is 'FK':
  1420.             All_To_Be_Made.append( x )     
  1421.         if Test_Is_Joint_Wanted is 'IKFK':
  1422.             All_To_Be_Made.append( x )             
  1423.         if Test_Is_Joint_Wanted is '_':
  1424.             print ( 'No joint being made for  ' + x + ' as requested \n')
  1425.         if Test_Is_Joint_Wanted is 'Aim_Affected': # treated as '_'
  1426.             print ( 'No joint being made for  ' + x + ' as requested \n')
  1427.         if Test_Is_Joint_Wanted is 'Aim_Target': # treated as '_'
  1428.             print ( 'No joint being made for  ' + x + ' as requested \n')
  1429.         if Test_Is_Joint_Wanted is 'PoleV': # treated as '_'
  1430.             print ( 'No joint being made for  ' + x + ' as requested \n')
  1431.  
  1432.            
  1433.    
  1434.            
  1435.     for x in All_To_Be_Made:
  1436.  
  1437.         cmds.select( clear = True )
  1438.         Guide_Trans = cmds.xform( ( x + '_Local_Jnt' )  , query=True , t=True , ws = True)
  1439.         Guide_Rots = cmds.xform( ( x + '_Local_Jnt' ) , query=True , ro=True , ws = True )
  1440.         Guide_Scale = cmds.xform( x , query=True , s=True , r=True )
  1441.         Guide_RotOrder = cmds.getAttr( ( x + '.' + 'rotateOrder') )
  1442.         pass #always check if something exists? if so delete and start over.. no exceptions.
  1443.  
  1444.         for Suffix_Found in Suffix_Joints:
  1445.             cmds.select( clear = True )
  1446.             NewJoint = cmds.joint ( n = ( x + Suffix_Found ) )
  1447.             cmds.select( clear = True )        
  1448.             RigBox_AddAllAtr( NewJoint , ( RigBox_ReadControlTypeAtr(x)) , (RigBox_ReadSystemTypeAtr(x)) , (RigBox_ReadPinTypeAtr(x)) , (RigBox_ReadExtraTypeAtr(x)) )
  1449.             tmp1 = cmds.parentConstraint( ( x + '_Local_Jnt' ) , NewJoint , mo = False )
  1450.             cmds.delete( tmp1 )        
  1451.             cmds.setAttr( ( NewJoint + '.' + 'rotateOrder') , Guide_RotOrder )
  1452.            
  1453.             pass #Unity style joint scaling?
  1454.             UnityScale = cmds.checkBox( 'Rig_Box_Check_UnityScale' , query=True , v=True )
  1455.             if UnityScale is True:
  1456.                 cmds.setAttr( ( NewJoint + '.segmentScaleCompensate' ) , 0 )
  1457.                 cmds.setAttr( ( NewJoint + '.ssc' ) , lock=True )  
  1458.             else:
  1459.                 pass
  1460.  
  1461.         for atr in IK_FK_Blend_Atr:
  1462.             Joint = ( x + Suffix_Joints[0] )
  1463.             cmds.addAttr( Joint , shortName = atr , attributeType = 'float' , min = 0.0 , max = 1.0 )  
  1464.             cmds.setAttr( ( Joint + '.' + atr ) , lock = False , channelBox = True )
  1465.             cmds.setAttr( ( Joint + '.' + atr ) , keyable = True )
  1466.  
  1467.        
  1468.    
  1469.    
  1470.     # pass # parenting section. Find the joint above given all circumstances.
  1471.     for Guide in All_To_Be_Made:
  1472.         FindParent = []
  1473.         count = 0
  1474.         cmds.select( clear = True )
  1475.         cmds.select( Guide )       
  1476.         while count < 2:   
  1477.             cmds.pickWalk( direction='up' )
  1478.             Current_Parent = cmds.ls( selection = True , transforms = True )   
  1479.             Parent_Legal = In_List_Test( Current_Parent[0] , All_To_Be_Made )
  1480.  
  1481.             if Parent_Legal is True:
  1482.                 print 'parent found for:'
  1483.                 print Guide
  1484.                 FindParent = Current_Parent
  1485.                 print FindParent
  1486.                 break
  1487.  
  1488.        
  1489.             count+=1
  1490.  
  1491.         if len( FindParent )  < 1:
  1492.             pass
  1493.         else:
  1494.             print ( str(Guide) + ' is to be the child of: \n' )
  1495.             print ( str(FindParent) + '\n' )
  1496.             for Suffix_Found in Suffix_Joints:
  1497.                 Joint_Legal_Parent = cmds.ls( ( FindParent[0] + Suffix_Found ) )
  1498.                 if len( Joint_Legal_Parent ) is 1:
  1499.                     cmds.parent( ( Guide + Suffix_Found ) , ( FindParent[0] + Suffix_Found ) )
  1500.                 else:
  1501.                     pass
  1502.                
  1503.     for Guide in All_To_Be_Made:   
  1504.         for Suffix_Found in Suffix_Joints:
  1505.             cmds.joint ( ( Guide + Suffix_Found ) , edit = True , setPreferredAngles = True , children= True)
  1506.  
  1507.  
  1508.        
  1509.     All_Joints = RigBox_FindAll( 'Joint' )
  1510.     All_Joints_FK = RigBox_FindAll( 'Joint_FK' )
  1511.     All_Joints_IK = RigBox_FindAll( 'Joint_IK' )
  1512.     All_Joints_IK_Extra = RigBox_FindAll( 'Joint_IK_Extra' )
  1513.  
  1514.     All_Joints_ParentsFound = RigBox_FindAncestor( All_Joints )
  1515.     if len( All_Joints_ParentsFound )  < 1:
  1516.         pass
  1517.     else:
  1518.         cmds.parent( All_Joints_ParentsFound , Joint_Grps[0] ,  )
  1519.  
  1520.     All_Joints_FK_ParentsFound = RigBox_FindAncestor( All_Joints_FK )
  1521.     if len( All_Joints_FK_ParentsFound )  < 1:
  1522.         pass
  1523.     else:
  1524.         cmds.parent( All_Joints_FK_ParentsFound , Joint_Grps[1] ,  )
  1525.  
  1526.     All_Joints_IK_ParentsFound = RigBox_FindAncestor( All_Joints_IK )
  1527.     if len( All_Joints_IK_ParentsFound )  < 1:
  1528.         pass
  1529.     else:
  1530.         cmds.parent( All_Joints_IK_ParentsFound , Joint_Grps[2] )
  1531.  
  1532.     All_Joints_IK_Extra_ParentsFound = RigBox_FindAncestor( All_Joints_IK_Extra )
  1533.     if len( All_Joints_IK_Extra_ParentsFound )  < 1:
  1534.         pass
  1535.     else:
  1536.         cmds.parent( All_Joints_IK_Extra_ParentsFound , Joint_Grps[3] )
  1537.    
  1538.        
  1539.     pass # Joints are now into the correct group.. 
  1540.     print 'Joints are now into the correct group..  \n'
  1541.    
  1542.     pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################     
  1543.     for x in All_To_Be_Made:
  1544.         Test_Is_Joint_IKFK = RigBox_ReadSystemTypeAtr( x )
  1545.        
  1546.         RigBox_Blend_3_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False ) 
  1547.         if Test_Is_Joint_IKFK == 'IKFK':
  1548.             cmds.setAttr( ( x + Suffix_Joints[0]  + '.' + IK_FK_Blend_Atr[0] ) , 1 ) # set up as fk default..
  1549.             pass # RigBox_Blend_3_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False )  
  1550.  
  1551.         if Test_Is_Joint_IKFK == 'IK':
  1552.             cmds.setAttr( ( x + Suffix_Joints[0]  + '.' + IK_FK_Blend_Atr[0] ) , 1 )
  1553.             pass # RigBox_Blend_2_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , 'UseCons' , False )
  1554.  
  1555.         if Test_Is_Joint_IKFK == 'FK':
  1556.             cmds.setAttr( ( x + Suffix_Joints[0]  + '.' + IK_FK_Blend_Atr[0] ) , 0 ) # set up as fk default..
  1557.             pass # RigBox_Blend_2_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False )
  1558.  
  1559.            
  1560. def RigBox_Guide_To_Rig()# starts the process of converting the guide items to a rig.
  1561.     global All_Controls_Made
  1562.     All_Controls_Made = [] 
  1563.  
  1564.     IK = []
  1565.     IKFK = []
  1566.     FK = []
  1567.     Control = []   
  1568.     PoleV = []
  1569.     Aim_Target = []
  1570.     Aim_Affected = []  
  1571.    
  1572.    
  1573.     All_Guides = RigBox_FindAll( 'Guide' )
  1574.     if len(All_Guides) < 1:
  1575.         print 'No Rig_Box_Joints found in the scene?'
  1576.     else:
  1577.         cmds.select( clear = True)  #begin the freezing of all guide objects!
  1578.         cmds.select( All_Guides )      
  1579.         Rig_Box_FrzGrouperCtrls()
  1580.  
  1581.         RigBox_RigGrpCleanup()  # cleaning up scene groups before working.
  1582.         RigBox_RigGrpCreate() # create all groups before working.
  1583.         RigBox_JointChainCreator() # create the ik fk and ikfk and binding up for all joints in the scene
  1584.         cmds.select( clear = True)  #begin the freezing of all guide objects!
  1585.  
  1586.        
  1587.        
  1588.         for x in All_Guides:
  1589.             RigBox_ControlCreate( x )
  1590.             Guide_System_Type = RigBox_ReadSystemTypeAtr( x )
  1591.             if Guide_System_Type == 'IKFK':
  1592.                 IKFK.append( x )
  1593.             if Guide_System_Type == 'IK':  
  1594.                 IK.append( x )
  1595.             if Guide_System_Type == 'FK':  
  1596.                 FK.append( x )         
  1597.             if Guide_System_Type == '_':
  1598.                 TestPinType = RigBox_ReadPinTypeAtr( x )
  1599.                 if TestPinType == '_':
  1600.                     Control.append( x )        
  1601.             if Guide_System_Type == 'PoleV':
  1602.                 PoleV.append( x )          
  1603.             if Guide_System_Type == 'Aim_Target':  
  1604.                 Aim_Target.append( x )         
  1605.             if Guide_System_Type == 'Aim_Affected':
  1606.                 Aim_Affected.append( x )           
  1607.  
  1608.         RigBox_PinCreator()
  1609.                
  1610.     if len( IK ) > 0:
  1611.         RigBox_Guide_To_Rig_IK( IK , 'IK' )
  1612.        
  1613.     if len( IKFK ) > 0:
  1614.  
  1615.         RigBox_Guide_To_Rig_FK( IKFK , 'IKFK' )
  1616.         RigBox_Guide_To_Rig_IK( IKFK , 'IKFK' )
  1617.        
  1618.     if len( FK ) > 0:  
  1619.         RigBox_Guide_To_Rig_FK( FK , 'FK' )
  1620.        
  1621.     if len( Control ) > 0
  1622.         RigBox_Guide_To_Rig_Control( Control )     
  1623.    
  1624.     if len( Aim_Affected ) > 0:
  1625.         RigBox_Guide_To_Rig_AimAffected( Aim_Affected )
  1626.    
  1627.     RigBox_SpaceSwitching() # set up the space switching if any are found..
  1628.     RigBox_Frz_Vis_All() # freezes visibility on all pieces made..
  1629.    
  1630. def RigBox_Guide_To_Rig_AimAffected( Items ): # used for setting up look at / aim at type constraints, eg eyes?!
  1631.     RigBox_Guide_To_Rig_Control( Items )
  1632.     print '\n Starting EyeAim Search process...'
  1633.    
  1634.     for Item in Items:
  1635.        
  1636.         Operation = None
  1637.        
  1638.         count = 0
  1639.         cmds.select( clear = True )
  1640.         cmds.select( Item )
  1641.  
  1642.         cmds.pickWalk( direction='up' )
  1643.         cmds.pickWalk( direction='up' )
  1644.  
  1645.         Current_Parent = cmds.ls( selection = True , transforms = True )   
  1646.         PossibleEyeAimList = cmds.listRelatives( Current_Parent[0] , c = True , type = 'transform' , ad = True )
  1647.  
  1648.         for PossibleEye in PossibleEyeAimList:
  1649.             pass # see if its a EyeAim type?
  1650.             TestPinType = RigBox_ReadPinTypeAtr( PossibleEye )
  1651.             if TestPinType == 'EyeAim':
  1652.  
  1653.                 Operation = PossibleEye
  1654.                 break  
  1655.                
  1656.         if Operation is None:
  1657.             pass
  1658.         else:
  1659.             print '\n'
  1660.             print ( Item + ' Is being aim targetted at:' )
  1661.             print Operation
  1662.             print '\n'
  1663.             cmds.aimConstraint( ( Operation + '_Control' ) , ( Item + '_Control' ) , aim = [ 0 , 1 , 0 ] , mo = True )
  1664.    
  1665.  
  1666. def RigBox_Guide_To_Rig_RollControl( Items ): # given multiple lists eg [ [big list 1] , [big list 2 etc] ] will create the footroll / handroll setup..
  1667.  
  1668.     for Set in Items:
  1669.         print 'Starting Reverse foot / hand roll setup:'
  1670.         print Set
  1671.         print '\n'
  1672.         pass # check if is set.
  1673.         MakeSureSetIsNotString = isinstance( Set , list)   
  1674.         if MakeSureSetIsNotString is False:
  1675.             print '\n foot roll possible issue'
  1676.             print Set
  1677.             print 'above Items are all that have been supplied. \n'
  1678.             tmp = [ Set ]
  1679.             Set = tmp
  1680.        
  1681.  
  1682.        
  1683.            
  1684.         Roll_Toe = None
  1685.         Roll_Toe_IK_Control = None  # fk version wont exist due to the nature of ik..
  1686.        
  1687.         Roll_Ball = None   
  1688.         Roll_Ball_FK_Control = None    
  1689.         Roll_Ball_IK_Control = None
  1690.         ##
  1691.         Roll_Heel = None
  1692.         Roll_Heel_FK_Control = ( Set[-2] + '_Control_FK' ) 
  1693.         Roll_Heel_IK_Control = ( Set[-2] + '_Control_IK' )
  1694.         Roll_HeelRev_IK_Control = None
  1695.        
  1696.  
  1697.         for Item in Set: # find and place in correct list the types..
  1698.        
  1699.             pass # first sort blend remaining joints!          
  1700.             TestExtraType = RigBox_ReadExtraTypeAtr( Item )
  1701.             if TestExtraType is not None:
  1702.                 if 'Roll' in TestExtraType:        
  1703.                     Connected = cmds.listConnections( ( Item + Suffix_Joints[1] + '.translate' ) , destination = True)
  1704.                     TestList = In_List_Test( ( Item + Suffix_Joints[3]  ) , Connected )
  1705.  
  1706.                     if TestList is not True:
  1707.                         print ( 'blending  ' + ( Item + Suffix_Joints[1] + '.t' ) + '   ' +  ( Item + Suffix_Joints[3] + '.t' ) )
  1708.                         RigBox_Blend_2_Items( ( Item + Suffix_Joints[1] ) , ( Item + Suffix_Joints[3] ) , 'UseBlends' , False )
  1709.                         cmds.connectAttr( ( Set[-2] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) )     
  1710.                    
  1711.        
  1712.         for Item in Set: # find and place in correct list the types..
  1713.        
  1714.             FindExtraType = RigBox_ReadExtraTypeAtr( Item )
  1715.            
  1716.             if FindExtraType == 'Roll_Toe':
  1717.                 Search = 'RollToe'
  1718.                 FullName = ( Item + '_' + Search  )
  1719.    
  1720.                 pass # creating roll toe control that will control the entire foot reverse.
  1721.                 Roll_Toe = Item
  1722.                 cmds.select( clear = True )
  1723.                 tmp = RigBox_Guide_PoleV('Auto') # create the guide version
  1724.                 tmp5 = cmds.duplicate( tmp , name = FullName , rc = True )
  1725.                 tmp2 = cmds.parentConstraint( ( Roll_Toe + '_Local_Jnt' ) , tmp5 , mo = False )
  1726.                 cmds.delete( tmp )                 
  1727.                 cmds.delete( tmp2 )
  1728.                 Roll_Toe_IK_Control = RigBox_ControlCreate( FullName ) # create the real controller version
  1729.                 cmds.delete( tmp5 )
  1730.                 cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_Toe_IK_Control + '.v' ) )
  1731.                
  1732.                
  1733.                
  1734.                
  1735.             if FindExtraType == 'Roll_Ball': # declaring what controls the heel ik, and also creating the control that will affect the ball -> toe
  1736.                 Roll_Ball = Item
  1737.                 New_IK_ControlGrp = cmds.duplicate( ( Item + '_Control_FK_Grp' ) , name = ( Item + '_Control_IK_Grp' ) , rc = True )
  1738.                 RigBox_RemoveAllAtr( New_IK_ControlGrp[0] )
  1739.                 Roll_Ball_IK_Control = cmds.rename( New_IK_ControlGrp[1] , ( Item + '_Control_IK' ) )
  1740.                 cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_Ball_IK_Control + '.v' ) )       
  1741.    
  1742.    
  1743.             if FindExtraType == 'Roll_Heel':
  1744.                 Search = 'RollHeel'
  1745.                 Roll_Heel = Item
  1746.  
  1747.                 Target = None
  1748.                 if Roll_Ball is not None:
  1749.                     FullName = ( Item + '_' + Search  )
  1750.                     tmp = RigBox_Guide_PoleV('Auto') # create the guide version
  1751.                     tmp2 = cmds.parentConstraint( Roll_Ball , tmp[0] , mo = False )                    
  1752.                     cmds.delete( tmp2 )
  1753.                     tmp3 = cmds.rename( tmp[0] , FullName )                
  1754.                     Roll_HeelRev_IK_Control = RigBox_ControlCreate( FullName ) # create the real controller version
  1755.                     cmds.delete( tmp3 )        
  1756.                     cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_HeelRev_IK_Control + '.v' ) )    
  1757.        
  1758.         if Roll_Toe is None:
  1759.             if Roll_Ball is None:      
  1760.                 if Roll_Heel is None:      
  1761.                     break
  1762.  
  1763.         pass # now to determine the type of roll we can do?
  1764.         ToeBall = False
  1765.         BallHeel = False       
  1766.         ToeHeel = False    
  1767.  
  1768.         Type = 0
  1769.        
  1770.         if Roll_Toe is not None:
  1771.             if Roll_Ball is not None:
  1772.                 ToeBall = True
  1773.                 Type +=1
  1774.                
  1775.         if Roll_Ball is not None:
  1776.             if Roll_Heel is not None:  
  1777.                 BallHeel = True
  1778.                 Type +=1
  1779.                
  1780.         if Roll_Toe is not None:
  1781.             if Roll_Heel is not None:  
  1782.                 ToeHeel = True 
  1783.                 Type +=1
  1784.            
  1785.         pass # setting up IK Handles
  1786.         ToeBall_Handle = None
  1787.         BallHeel_Handle = None
  1788.         ToeHeel_Handle = None
  1789.         Heel_Handle = ( Set[-1] + '_Handle_IK' )       
  1790.        
  1791.         pass # now break the original ik constraint on the heel handle.
  1792.         Heel_IK_HandleCons = cmds.parentConstraint( Heel_Handle , q = True )
  1793.         if len( Heel_IK_HandleCons ) is not None:
  1794.             cmds.delete( Heel_IK_HandleCons )  
  1795.        
  1796.         if Type is 3: # full foot version?
  1797.        
  1798.             if ToeBall is True:
  1799.                 Handle_Main = cmds.ikHandle( sj = ( Roll_Ball + Suffix_Joints[3] ) , ee = ( Roll_Toe + Suffix_Joints[3] ) , n = ( Roll_Ball + Roll_Toe + '_Handle_Roll_BallToe' ) , sol = 'ikSCsolver' , srp = True , s = "sticky" ) #ik handle
  1800.                 ToeBall_Handle = Handle_Main[0]
  1801.                 cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
  1802.  
  1803.             if BallHeel is True:
  1804.                 Handle_Main = cmds.ikHandle( sj = ( Roll_Heel + Suffix_Joints[3] ) , ee = ( Roll_Ball + Suffix_Joints[3] ) , n = ( Roll_Ball + Roll_Heel + '_Handle_Roll_BallHeel' ) , sol = 'ikSCsolver' , srp = True , s = "sticky" ) #ik handle
  1805.                 BallHeel_Handle = Handle_Main[0]
  1806.                 cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
  1807.                
  1808.             Ball_to_HeelCons = cmds.parentConstraint( Roll_HeelRev_IK_Control , Heel_Handle , mo = True )  
  1809.             Heel_to_BallCons = cmds.parentConstraint( Roll_Ball_IK_Control , BallHeel_Handle , mo = True ) 
  1810.             Heel_to_BallCons = cmds.parentConstraint( Roll_Ball_IK_Control , ToeBall_Handle , mo = True )  
  1811.             RollToe_Cons = cmds.parentConstraint( Roll_Toe_IK_Control ,  (Roll_Ball_IK_Control + '_Grp' ) , mo = True )
  1812.             RollToe_Cons = cmds.parentConstraint( Roll_Toe_IK_Control ,  ( Roll_HeelRev_IK_Control + '_Grp' ) , mo = True )
  1813.             HeelMaster_Cons = cmds.parentConstraint( Roll_Heel_IK_Control ,  ( Roll_Toe_IK_Control + '_Grp' ) , mo = True )
  1814.                
  1815.            
  1816.             Immediate_Children = cmds.listRelatives( Roll_Toe , children = True )  
  1817.             if len( Immediate_Children ) > 2:
  1818.                 tmp = Immediate_Children[2:]
  1819.                 cmds.select( clear = True )
  1820.                 for x in tmp:
  1821.                     cmds.select( ( x + '_PinMaster' ) , add = True )
  1822.                     cmds.pickWalk( d = 'down' )
  1823.                     cmds.pickWalk( d = 'left' )
  1824.                     cmds.delete()
  1825.                     cmds.parentConstraint(  ( Roll_Toe + '_Jnt' ) , ( x + '_PinMaster' ) , mo = True ) 
  1826.  
  1827.                
  1828.         if Type < 3:        # hand version?    
  1829.                
  1830.             if ToeHeel is True:
  1831.                 Handle_Main = cmds.ikHandle( sj = ( Roll_Heel + Suffix_Joints[3] ) , ee = ( Roll_Toe + Suffix_Joints[3] ) , n = ( Roll_Toe + Roll_Heel + '_Handle_Roll_ToeHeel' ) , sol = 'ikSCsolver' , srp = True , s = "sticky" ) #ik handle
  1832.                 ToeHeel_Handle = Handle_Main[0]
  1833.                 cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
  1834.  
  1835.             Toe_to_HeelCons = cmds.parentConstraint( Roll_Toe_IK_Control , Heel_Handle , mo = True )   
  1836.             Toe_to_HeelCons = cmds.parentConstraint( Roll_Toe_IK_Control , ToeHeel_Handle , mo = True )
  1837.  
  1838.             HeelMaster_Cons = cmds.parentConstraint( Roll_Heel_IK_Control ,  ( Roll_Toe_IK_Control + '_Grp' ) , mo = True )
  1839.  
  1840.    
  1841.             Immediate_Children = cmds.listRelatives( Roll_Toe , children = True )  
  1842.             if len( Immediate_Children ) > 2:
  1843.                 tmp = Immediate_Children[2:]
  1844.                 cmds.select( clear = True )
  1845.                 for x in tmp:
  1846.                     cmds.select( ( x + '_PinMaster' ) , add = True )
  1847.                     cmds.pickWalk( d = 'down' )
  1848.                     cmds.pickWalk( d = 'left' )
  1849.                     cmds.delete()
  1850.                     cmds.parentConstraint(  ( Roll_Toe + '_Jnt' ) , ( x + '_PinMaster' ) , mo = True ) 
  1851.  
  1852.                
  1853.                
  1854.    
  1855.    
  1856. def RigBox_Guide_To_Rig_IK( Items , Mode ):  ## IK SYSTEM
  1857.     print 'ikwip'
  1858.  
  1859.     All_IK_Found = []
  1860.     All_IK_Starts_Found = []
  1861.     All_IK_Ends_Found = [] 
  1862.    
  1863.     pass # finding the start of all IK guide types.
  1864.     for x in Items:
  1865.         SystemType = RigBox_ReadSystemTypeAtr( x )
  1866.         if SystemType ==  Mode :
  1867.             All_IK_Found.append( x )
  1868.        
  1869.     All_IK_Found_As_Joints = []
  1870.     for x in Items:
  1871.         All_IK_Found_As_Joints.append( ( x + Suffix_Joints[3] ) )  
  1872.    
  1873.     print 'All ik Joints found'
  1874.     print   All_IK_Found_As_Joints
  1875.     print '\n'
  1876.    
  1877.    
  1878.     pass # find all the IK ENDS!
  1879.     for x in All_IK_Found_As_Joints:
  1880.         cmds.select( clear = True )
  1881.         cmds.select( x )
  1882.         current = cmds.ls( selection = True )
  1883.         Immediate_Children = cmds.listRelatives( current , children = True )   
  1884.         if Immediate_Children is None:
  1885.             All_IK_Ends_Found.append( current[0].replace( Suffix_Joints[3] , '' ) ) # its the end of a chain, but also ik
  1886.         else:
  1887.             Still_IK = False
  1888.             for child in Immediate_Children:
  1889.                 SystemType_Test = RigBox_ReadSystemTypeAtr( child )
  1890.                 if SystemType_Test == Mode:
  1891.                     Still_IK = True # ik found, go deeper..
  1892.             if Still_IK is False:
  1893.                 All_IK_Ends_Found.append( current[0].replace( Suffix_Joints[3] , '' ) )
  1894.  
  1895.                
  1896.     pass # find all the IK STARTS!             
  1897.     for x in All_IK_Found_As_Joints:
  1898.         cmds.select( clear = True )
  1899.         cmds.select( x )
  1900.         current = x
  1901.         Immediate_Parents = cmds.listRelatives( current , parent = True )      
  1902.  
  1903.         if len( Immediate_Parents ) > 0:   
  1904.             IsIn_IK_List_Test = In_List_Test( Immediate_Parents[0] , All_IK_Found_As_Joints )
  1905.             if IsIn_IK_List_Test is None:
  1906.                 print ( 'Start of IK ' + current.replace( Suffix_Joints[3] , '' ) )
  1907.                 All_IK_Starts_Found.append( current.replace( Suffix_Joints[3] , '' ) ) # its the start of a chain, but also ik
  1908.    
  1909.    
  1910.     All_IK_Mids_Found = All_IK_Found
  1911.     print ( 'All IK Starts found: ' )
  1912.     print All_IK_Starts_Found
  1913.     print ( 'All IK Ends found: ' )
  1914.     print All_IK_Ends_Found
  1915.     print '\n'
  1916.    
  1917.     pass # To find all the middle IK Controls that will need to be rigged up.
  1918.     for x in All_IK_Mids_Found:
  1919.         IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Ends_Found )
  1920.         if IsIn_IK_List_Test_Start is True:
  1921.             All_IK_Mids_Found.remove( x )
  1922.             print ( 'removing from IK Mids:  ' + x )
  1923.  
  1924.     for x in All_IK_Mids_Found:
  1925.         IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Starts_Found )
  1926.         if IsIn_IK_List_Test_Start is True:
  1927.             All_IK_Mids_Found.remove( x )  
  1928.             print ( 'removing from IK Mids:  ' + x )
  1929.            
  1930.     pass # To find all the middle IK Controls that will need to be rigged up.
  1931.     for x in All_IK_Mids_Found:
  1932.         IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Ends_Found )
  1933.         if IsIn_IK_List_Test_Start is True:
  1934.             All_IK_Mids_Found.remove( x )
  1935.             print ( 'removing from IK Mids:  ' + x )   
  1936.            
  1937.     for x in All_IK_Mids_Found:
  1938.         IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Starts_Found )
  1939.         if IsIn_IK_List_Test_Start is True:
  1940.             All_IK_Mids_Found.remove( x )  
  1941.             print ( 'removing from IK Mids:  ' + x )           
  1942.            
  1943.            
  1944.  
  1945.     print ('ik mids now = :' )
  1946.     for x in All_IK_Mids_Found:
  1947.         print x
  1948.     print '\n'
  1949.  
  1950.    
  1951.     def RigBox_IK_Mid_Cons( Item , Mode  ):
  1952.         IK_Break_Test = cmds.getAttr( ( Item.replace( Suffix_Joints[3] , '' ) ) + '.' +  Extra_Options[0] ) #IF_IK_allow_Breakable_IK_Setup
  1953.  
  1954.         Grps = []
  1955.         Jnts = []
  1956.        
  1957.         Test_Local = RigBox_ReadExtraTypeAtr( Item )   
  1958.         if Test_Local == 'Local':
  1959.             Grps.append( Item + '_Control_IK_Grp' )
  1960.             Grps.append( Item + '_Control_Local_IK_Grp' )
  1961.             Jnts.append( Item + Suffix_Joints[3] )         
  1962.             Jnts.append( Item + Suffix_Joints[3] )         
  1963.            
  1964.         else:
  1965.             Grps.append( Item + '_Control_IK_Grp' )
  1966.             Jnts.append( Item + Suffix_Joints[3] )
  1967.                
  1968.         count = 0
  1969.         while count < len(Grps):
  1970.             if IK_Break_Test is 0: # allowed go ahead
  1971.                 Grp = Grps[ count ]
  1972.                 Joint = Jnts[ count ]
  1973.                 cmds.parentConstraint( Joint , Grp , mo = True )   
  1974.             if IK_Break_Test is 1: # NOT allowed, hide control instead.
  1975.                 Grp = Grps[ count ]
  1976.                 Joint = Jnts[ count ]
  1977.                 cmds.parentConstraint( Joint , Grp , mo = True )   
  1978.                 cmds.setAttr( ( Grp + '.v' ) , 0 )     
  1979.             count+=1
  1980.    
  1981.        
  1982.     IK_Go = False
  1983.     if len( All_IK_Starts_Found ) is len( All_IK_Ends_Found ):
  1984.         if All_IK_Starts_Found[0] == All_IK_Ends_Found[0]:
  1985.             print 'Possible issue with IK handles, number of IK starts and IK ends dont match?'
  1986.         else:
  1987.             print 'Starting IK Handles, all seems well'
  1988.             IK_Go = True
  1989.     else:
  1990.         print 'Possible issue with IK handles, number of IK starts and IK ends dont match?'
  1991.  
  1992.        
  1993.     IK_Handles = []
  1994.     Solver = 'ikRPsolver'
  1995.     pass # Solver = 'ikSCsolver'   
  1996.    
  1997.     if IK_Go is True:
  1998.      for x in All_IK_Mids_Found:
  1999.         RigBox_IK_Mid_Cons( x , Mode )
  2000.    
  2001.     if IK_Go is True:
  2002.         pass # creating all the IK Handle..
  2003.         count = 0
  2004.         while count < len( All_IK_Starts_Found ):
  2005.             Start = All_IK_Starts_Found[ count ]
  2006.            
  2007.             FindParent_Start = cmds.listRelatives( ( Start + Suffix_Joints[1] ) , parent = True )
  2008.             if FindParent_Start[0] == Joint_Grps[2]:
  2009.                 pass
  2010.             else:
  2011.                 cmds.parent( ( Start + Suffix_Joints[1] ) , Joint_Grps[2] ) # operation on the normal ik
  2012.                 cmds.parent( ( Start + Suffix_Joints[3] ) , Joint_Grps[3] ) # operation on the ik extra..          
  2013.                
  2014.             pass # items re-parented if need be!   
  2015.             cmds.joint ( ( Start + Suffix_Joints[1] ) , edit = True , setPreferredAngles = True , children= True)
  2016.             cmds.joint ( ( Start + Suffix_Joints[3] ) , edit = True , setPreferredAngles = True , children= True)
  2017.    
  2018.                
  2019.             End = All_IK_Ends_Found[ count ]
  2020.            
  2021.             print Start
  2022.             print End
  2023.             Handle_Main = cmds.ikHandle( sj = ( Start + Suffix_Joints[3] ) , ee = ( End + Suffix_Joints[3] ) , n = ( Start + '_Handle_IK' ) , sol = Solver , srp = True , s = "sticky" ) #ik handle
  2024.             cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
  2025.    
  2026.    
  2027.             pass # Constrain the start of the Handle
  2028.             Test_Local = RigBox_ReadExtraTypeAtr( Start )  
  2029.  
  2030.             if Test_Local == 'Local':
  2031.                 Additional = '_Local_IK'
  2032.             else:
  2033.                 Additional = '_IK'             
  2034.             cmds.pointConstraint( ( Start + '_Control' + Additional ) , ( Start + Suffix_Joints[3] ) , mo = True )
  2035.             cmds.orientConstraint( ( Start + Suffix_Joints[3] ) , ( Start + '_Control' + Additional ) , mo = False )           
  2036.             ##Start control is edited here that controls the start of ik chain but no rotation should be allowed.
  2037.             cmds.setAttr( ( Start + '_Control' + Additional  +'.rotateX' ) , keyable = False )
  2038.             cmds.setAttr( ( Start + '_Control' + Additional  +'.rotateY' ) , keyable = False )     
  2039.             cmds.setAttr( ( Start + '_Control' + Additional  +'.rotateZ' ) , keyable = False )
  2040.             cmds.setAttr( ( Start + '_Control' + Additional + '.v' ) , lock = True , keyable = False ,
  2041.             channelBox = False )       
  2042.             cmds.setAttr( ( End + '_Control' + Additional + '.v' ) , lock = True , keyable = False ,
  2043.             channelBox = False )       
  2044.  
  2045.            
  2046.             pass # now constrain the start controls group to the correct pin!
  2047.             cmds.parentConstraint( ( Start + '_PinFollow' ) , ( Start + '_Control_IK_Grp' ) , mo = True )          
  2048.            
  2049.  
  2050.             pass # Constrain the end of the Handle
  2051.             Test_Local = RigBox_ReadExtraTypeAtr( End )
  2052.             if Test_Local == 'Local':
  2053.                 Additional = '_Local_IK'
  2054.             else:
  2055.                 Additional = '_IK' 
  2056.             cmds.parentConstraint( ( End + '_Control' + Additional ) , Handle_Main[0] , mo = True )        
  2057.             cmds.orientConstraint( ( End + '_Control' + Additional ) , ( End + Suffix_Joints[3] ) , mo = False ) #orient constraining the ik start control to the joint since you cant rotate anyway.
  2058.    
  2059.             IK_Handles.append( Handle_Main[0] ) #add to the handles list.
  2060.  
  2061.        
  2062.            
  2063.             print 'twatish'
  2064.            
  2065.             pass # PoleVector stage!
  2066.             pass # Find if one has already been added to the guides?
  2067.             pass # grab a list of all the joints affected by the current handle
  2068.             Joint_List_Affected = cmds.ikHandle( Handle_Main[0] , query = True , jl= True )
  2069.             cmds.select( Joint_List_Affected[-1] )
  2070.             cmds.pickWalk( d = 'down' )
  2071.             Extra_Joint = cmds.ls( selection = True , type = 'joint')
  2072.             Joint_List_Affected.append( Extra_Joint[0] )
  2073.            
  2074.             Pole = []
  2075.            
  2076.             Guides = []
  2077.             for Joint in Joint_List_Affected:
  2078.                 tmp44 = Joint.replace( Suffix_Joints[3] , '' )
  2079.                 Guides.append( tmp44 )
  2080.            
  2081.             PoleTest = RigBox_IK_PoleFind( Guides )
  2082.             if PoleTest == 'Not Found':
  2083.                 print 'poley not foundy'
  2084.                 pass # no object found, will make a default version instead
  2085.                 print 'jnts used for pole v:'
  2086.                 print Joint_List_Affected
  2087.                 World_Position = RigBox_IK_PolePosition( Joint_List_Affected )
  2088.                 cmds.select( clear = True )
  2089.                 cmds.select( Guides[0] )
  2090.                 tmp = RigBox_Guide_PoleV('Auto') # create the guide version
  2091.                 cmds.xform( tmp , t = World_Position , ws = True )             
  2092.                 PoleTest = tmp[0]
  2093.                 RigBox_ControlCreate( PoleTest ) # create the real controller version
  2094.                
  2095.                
  2096.             pass #  constrain the pole vector / ik handle. 
  2097.             MakeSureNameIsString = isinstance( PoleTest , str) 
  2098.             if MakeSureNameIsString is True:
  2099.                 pass
  2100.             else:
  2101.                 PoleTest = ''.join(PoleTest)   
  2102.            
  2103.            
  2104.            
  2105.             cmds.poleVectorConstraint( ( PoleTest + '_Control_IK' ) , Handle_Main[0] )
  2106.             pass # setup the visibility of the control.
  2107.             cmds.connectAttr( ( Joint_List_Affected[0].replace( Suffix_Joints[3] , Suffix_Joints[0] ) + '.' + IK_FK_Blend_Atr[0] ) , ( PoleTest + '_Control_IK' + '.v' ) ) 
  2108.  
  2109.             pass # now to add the final control if ikfk.
  2110.             if Mode == 'IKFK':
  2111.                 End_Guide = Guides[-1]
  2112.                 End_Joint = ( End_Guide + Suffix_Joints[0] )
  2113.                 cmds.select( clear = True )
  2114.                 cmds.select(End_Joint)
  2115.                 cmds.pickWalk( d = 'up' )
  2116.                
  2117.                 Second_TO_End_Joint = cmds.ls( selection = True , type = 'joint' )
  2118.                 End_Control_Name = ( End_Guide + '_IKFK' )
  2119.                 cmds.select( clear = True )
  2120.                 pass # create the control object.
  2121.                 Fake_Control = RigBox_Guide_Piece( End_Control_Name , 'IKFK' )
  2122.                
  2123.                 Real_Control = RigBox_ControlCreate( Fake_Control[0] ) # create the real controller version
  2124.                 cmds.delete( Fake_Control )
  2125.                
  2126.                
  2127.                 for x in Guides: # connect up the joints own ikfk attribute to the main switch!
  2128.                     IKFK_Joint = ( x + Suffix_Joints[0] )
  2129.                     cmds.connectAttr(  ( Real_Control + '.FK_IK_Switch' )   , ( IKFK_Joint + '.' + IK_FK_Blend_Atr[0] ) )  
  2130.            
  2131.                 pass # now to pin the switch to the end joint in the right place.
  2132.                 cmds.parentConstraint( End_Joint , ( End_Control_Name + '_Control_Grp' ) , mo = False )
  2133.                 pass # now to find the axis to move in.
  2134.                 Axis = FindAxis_Direction( ( End_Joint , Second_TO_End_Joint ) , 'Away' )
  2135.                 To_Move =  ChainLength( ( Second_TO_End_Joint , End_Joint ) )
  2136.                 cmds.setAttr( ( End_Control_Name + '_Control.' + Axis ) , ( To_Move * .6 )  )   # go crazy all out on a scale.
  2137.  
  2138.                 #now connect the twist override to the right IK handle:
  2139.                 cmds.connectAttr( ( Real_Control + '.FK_IK_TwistOveride' ) , ( Handle_Main[0] + ".twist" ) )   
  2140.                
  2141.                
  2142.            
  2143.            
  2144.            
  2145.             count+=1           
  2146.            
  2147.         No_IKBreak_Setup( IK_Handles )
  2148.  
  2149.         if len( All_IK_Ends_Found ) > 0:
  2150.             print 'ALL IK ENDS FOUND :'
  2151.             print All_IK_Ends_Found
  2152.            
  2153.             count = 0
  2154.             for x in All_IK_Ends_Found:
  2155.                 ListOfChildLists = []
  2156.                 ChildrenFound = cmds.listRelatives( x , c = True , ad = True , type = 'transform' ) # should feed back a list
  2157.                 ChildrenFound.append( x ) # adding the end joint!
  2158.                 ChildrenFound.append( All_IK_Starts_Found[ count ] ) # adding the end joint!               
  2159.                 ListOfChildLists.append( ChildrenFound )
  2160.                 RigBox_Guide_To_Rig_RollControl( ListOfChildLists )
  2161.                 count+=1       
  2162.     else:
  2163.         pass
  2164.  
  2165.  
  2166. def No_IKBreak_Setup( Handles ): # does the vanilla setup of no stretch ik.
  2167.     pass # fancy version is still wip, normal versions works perfectly.
  2168.     for Handle in Handles:
  2169.         Joint_List_Affected = cmds.ikHandle( Handle , query = True , jl= True )
  2170.         cmds.select( Joint_List_Affected[-1] )
  2171.         cmds.pickWalk( d = 'down' )
  2172.         Extra_Joint = cmds.ls( selection = True , type = 'joint')
  2173.         Joint_List_Affected.append( Extra_Joint[0] )
  2174.        
  2175.        
  2176.         pass # is IK Breakable On?
  2177.         IK_Break_Test = cmds.getAttr( ( Joint_List_Affected[0].replace( Suffix_Joints[3] , '' ) ) + '.' +  Extra_Options[0] ) #IF_IK_allow_Breakable_IK_Setup  
  2178.         print Joint_List_Affected[0].replace( Suffix_Joints[3] , '' )
  2179.        
  2180.         if IK_Break_Test is 0:
  2181.             pass # IK Break is on
  2182.             print 'ik breakable is wip'
  2183.             print Joint_List_Affected
  2184.             Solver = 'ikRPsolver'
  2185.  
  2186.             pass # Creating IK Handles for each 2 joints found in the above then Con straining all them to the correct controls
  2187.  
  2188.             count = 0
  2189.             while count < len( Joint_List_Affected ):
  2190.                 if ( count + 1 ) < ( len( Joint_List_Affected ) ):
  2191.                     Start = ( Joint_List_Affected[ count ].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
  2192.                     End = ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
  2193.                     Name = ( Joint_List_Affected[ count ] )
  2194.  
  2195.                     Handle_Chain = cmds.ikHandle( sj = Start , ee = End , n = ( Name + '_Chain_Handle_IK' ) , sol = Solver , srp = True , s = "sticky" ) #ik handle
  2196.                     cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
  2197.                    
  2198.                     Test_Local = RigBox_ReadExtraTypeAtr( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[1] , '' ) ) )  
  2199.                     if Test_Local == 'Local':
  2200.                         Additional = '_Local_IK'
  2201.                     else:
  2202.                         Additional = '_IK'
  2203.  
  2204.                     Control_Start = ( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
  2205.  
  2206.                     cmds.orientConstraint( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[3] , '' )) , Control_Start  , mo = False )
  2207.                    
  2208.                     Test_Local = RigBox_ReadExtraTypeAtr( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[1] , '' ) ) )  
  2209.                     if Test_Local == 'Local':
  2210.                         Additional = '_Local_IK'
  2211.                     else:
  2212.                         Additional = '_IK'
  2213.  
  2214.                     Control_End = ( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
  2215.  
  2216.                    
  2217.                    
  2218.                     pass # constrain the handles in place correctly.
  2219.                     ToBeConstrained_To = ( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
  2220.                     cmds.pointConstraint( ToBeConstrained_To , Handle_Chain[0] , mo = True )           
  2221.  
  2222.                     pass # now create the distance nodes for each handle to compare length against.
  2223.                     Length = ChainLength( ( Start , End ) )
  2224.                     Distance_NodeOutPut = DistanceNode_Setup( Control_Start , Control_End , Name )
  2225.                     # MultiDivide_NodeOutPut = MultiDivNode_Setup( Distance_Node , Length , Name , 2 )
  2226.                     ChannelToConnect = FindAxis_Direction( ( Start , End ) , 'Along' )
  2227.                     cmds.connectAttr( Distance_NodeOutPut , ( End + '.' + ChannelToConnect ) )
  2228.  
  2229.                     # need to use condition nodes,
  2230.                     # first only allow if the break is on
  2231.                     # check against the chain length.
  2232.                    
  2233.                 count+=1
  2234.                
  2235.                
  2236.            
  2237.            
  2238.            
  2239.            
  2240.            
  2241.             pass # cons the start joint to the correct control.
  2242.             JointStartToCons = ( Joint_List_Affected[0].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
  2243.  
  2244.             Guide = Joint_List_Affected[0].replace( Suffix_Joints[3] , '' )
  2245.             Test_Local = RigBox_ReadExtraTypeAtr( Guide )  
  2246.             if Test_Local == 'Local':
  2247.                 Additional = '_Local_IK'
  2248.             else:
  2249.                 Additional = '_IK'         
  2250.            
  2251.             ControlToConsTo = ( Guide + '_Control' + Additional )
  2252.             cmds.pointConstraint( ControlToConsTo , JointStartToCons , mo = True ) 
  2253.             cmds.orientConstraint(  ControlToConsTo , JointStartToCons , mo = True )   
  2254.             print 'cunt'
  2255.             #need to constrain the control orientation to the ik joint as its not animateable and will look funky.
  2256.    
  2257.  
  2258.            
  2259.             # count = 0
  2260.             # while count < len( Joint_List_Affected ):        
  2261.    
  2262.    
  2263.    
  2264.    
  2265.    
  2266.                 # count+=1 
  2267.    
  2268.    
  2269.    
  2270.    
  2271.         if IK_Break_Test is 1: # IK Break is off, boring.
  2272.             pass # IK Break is off
  2273.             for joint in Joint_List_Affected:
  2274.                 print 'basic ik blending'
  2275.                 RigBox_Blend_2_Items( ( joint.replace( Suffix_Joints[3] , Suffix_Joints[1] ) ) , ( joint.replace( Suffix_Joints[1] , Suffix_Joints[3] ) ) , 'UseBlends' , False )
  2276.  
  2277.    
  2278.        
  2279.  
  2280.  
  2281.  
  2282.    
  2283. def DistanceNode_Setup( Start , End , Name ): # creates a distance node named item_dn
  2284.     Tmp_Node = cmds.shadingNode( 'distanceBetween' , asUtility = True , name = ( Name + '_Dist_node')  )
  2285.     cmds.connectAttr( ( Start + '.worldMatrix' ) , ( Tmp_Node + '.inMatrix1' ) )
  2286.     cmds.connectAttr( ( End + '.worldMatrix' ) , ( Tmp_Node + '.inMatrix2' ) )     
  2287.     return ( Tmp_Node + '.distance' )
  2288.        
  2289.  
  2290. def MultiDivNode_Setup( Input1_Item , Input2_Float , Name , Operation ): # creates a multiply and divide node named item_dn
  2291.     pass # Operation , 1 is multiply, 2 is divide , 3 is power.
  2292.     Tmp_Node = cmds.shadingNode( 'multiplyDivide' , asUtility = True , name = ( Name + '_MultiDist_node')  )
  2293.     cmds.connectAttr( Input1_Item , ( Tmp_Node + '.input1X' ) )
  2294.     cmds.setAttr( ( Tmp_Node + '.input2X' ) , Input2_Float ) # set the float value
  2295.     cmds.setAttr( ( Tmp_Node + '.operation' ) , Operation ) #FULL Stretch..
  2296.     return ( Tmp_Node + '.outputX' )
  2297.  
  2298. def ConditionNode_Setup( Input1_Item , Input2_Item , Name , Operation ): # creates a multiply and divide node named item_dn
  2299.     pass # Operation , 1 is multiply, 2 is divide , 3 is power.
  2300.     Tmp_Node = cmds.shadingNode( 'condition' , asUtility = True , name = ( Name + '_Condition_node')  )
  2301.  
  2302.     cmds.setAttr( ( Tmp_Node + '.firstTerm' ) , Input1_Item )  
  2303.     cmds.setAttr( ( Tmp_Node + '.secondTerm' ) , Input2_Item )
  2304.     cmds.setAttr( ( Tmp_Node + '.operation' ) , Operation )
  2305.    
  2306.     # return output if True
  2307.     # return output if False   
  2308.    
  2309.    
  2310. def FindAxis_Direction( Input , Type ):
  2311.     Channels = [ 'sx' , 'sy' , 'sz' ]
  2312.     Channels_Ts = [ 'tx' , 'ty' , 'tz' ]   
  2313.     Chan_Results = []
  2314.  
  2315.     Items = []
  2316.    
  2317.     for x in Input:
  2318.         MakeSureNameIsString = isinstance( x , str)
  2319.         if MakeSureNameIsString is True:
  2320.             pass
  2321.         else:
  2322.             x = ''.join(x)
  2323.         Items.append( x )
  2324.    
  2325.     pass # move a point to between the 2 points in space.
  2326.     tmp = cmds.spaceLocator()
  2327.     tmp_cons = cmds.parentConstraint( Items[0] , tmp , mo = False )
  2328.     cmds.parentConstraint( Items[1] , tmp , mo = False )       
  2329.     cmds.delete( tmp_cons )
  2330.    
  2331.     Scale_Pivot = cmds.group( em = True )       #doesnt exhist, make it.
  2332.     tmp_scale_cons = cmds.parentConstraint( Items[0] , Scale_Pivot , mo = False )      
  2333.     cmds.delete( tmp_scale_cons )
  2334.     cmds.parent( tmp , Scale_Pivot )   
  2335.    
  2336.     Control_Distance = ChainLength( ( Items[0] , tmp ) )   
  2337.    
  2338.     for chan in Channels:
  2339.         cmds.scale( 1 , 1 , 1 , Scale_Pivot )
  2340.         cmds.setAttr( ( Scale_Pivot + '.' + chan ) ,  2 )  
  2341.         Chan_Results.append( ( ChainLength( ( Items[0] , tmp ) ) )  )  
  2342.  
  2343.     Channel_To_Use = ''        
  2344.     pass # print Input
  2345.     pass # print Chan_Results
  2346.    
  2347.     if Type == 'Away':
  2348.         tmp33 = min(enumerate( chan ) , key = lambda x: x[1])[0]
  2349.         Channel_To_Use = Channels_Ts[ tmp33 ]  
  2350.        
  2351.     if Type == 'Along':
  2352.         tmp33 = min(enumerate( chan ), key = lambda x: abs(x[1]- Control_Distance ))   
  2353.         Channel_To_Use = Channels_Ts[ tmp33[0] ]
  2354.        
  2355.     pass # now we know which channel laid along or away from the axis.! yay
  2356.     cmds.delete( tmp ) # reset the damage.
  2357.     cmds.delete( Scale_Pivot ) # reset the damage.
  2358.  
  2359.            
  2360.     return Channel_To_Use
  2361.  
  2362.    
  2363. def ChainLength( Items ):   # returns the distance from start to end in world space of the supplied items.
  2364.     Distances = []
  2365.     import math
  2366.     count = 0
  2367.     while ( count + 1 ) < len( Items ):
  2368.         Pos1 = cmds.xform( Items[ count ] , query = True , t = True , ws = True)   
  2369.         Pos2 = cmds.xform( Items[ ( count + 1 ) ] , query = True , t = True , ws = True)
  2370.         Xd = ( Pos1[0] - Pos2[0] )
  2371.         Xd = ( Xd * Xd )
  2372.         Yd = ( Pos1[1] - Pos2[1] )
  2373.         Yd = ( Yd * Yd )
  2374.         Zd = ( Pos1[2] - Pos2[2] )
  2375.         Zd = ( Zd * Zd )
  2376.         Distance = math.sqrt( Xd + Yd + Zd )
  2377.         Distances.append( Distance )       
  2378.         count+=1
  2379.     return sum( Distances )
  2380.  
  2381.    
  2382. def Rigbox_IKPole_UIMover(): # simple script that will move the selected pole object to the correct world position in a hierachy. # user needs to select the start of ik chain and proceeding items then the polevecor to move..
  2383.     Items = cmds.ls( selection = True )
  2384.     Pole = Items[-1]
  2385.     NewItems = Items[0: (len( Items ) - 1)]
  2386.     print ( NewItems )
  2387.     NewPosition = RigBox_IK_PolePosition( Items )
  2388.     cmds.xform( Pole , t = NewPosition , ws = True ) # move the pivot perfectly to correct world space!
  2389.    
  2390.    
  2391.    
  2392.    
  2393. def RigBox_IK_PolePosition( Items ):
  2394.  
  2395.     Pole_Position =[ 0.0 , 0.0 , 0.0 ]
  2396.    
  2397.     if len( Items ) is 2:
  2398.         pass # using 2 items.
  2399.         tmp = cmds.spaceLocator()
  2400.         tmp_cons = cmds.parentConstraint( Items[0] , tmp , mo = False )
  2401.         cmds.parentConstraint( Items[1] , tmp , mo = False )       
  2402.         cmds.delete( tmp_cons )
  2403.        
  2404.        
  2405.         Channel_To_Use = FindAxis_Direction( Items , 'Away' )          
  2406.         Control_Distance = ChainLength( ( Items[0] , tmp ) )
  2407.            
  2408.         cmds.setAttr( ( tmp[0] + '.' + Channel_To_Use ) ,  Control_Distance )   # go crazy all out on a scale.
  2409.         pass # cmds.setAttr( ( Scale_Pivot + '.' + Chan_Results[0] ) ,  2.5 )   # go crazy all out on a scale.
  2410.         Pole_Position = cmds.xform( tmp , query = True , t = True , ws = True)
  2411.         cmds.delete( tmp ) 
  2412.  
  2413.  
  2414.     if len( Items ) > 2:
  2415.         pass # using 3 items.
  2416.        
  2417.         tmp = cmds.spaceLocator()
  2418.         tmp_pin = cmds.spaceLocator()
  2419.         tmp_knee = cmds.spaceLocator() 
  2420.         cmds.parent( tmp_pin , tmp )
  2421.         cmds.parent( tmp_knee , tmp )  
  2422.         tmp_point_cons = cmds.pointConstraint( Items[0] , Items[-1] , tmp_knee )   
  2423.            
  2424.         cmds.pointConstraint( Items[0] , tmp )
  2425.         cmds.pointConstraint( Items[-1] , tmp_pin )    
  2426.         cmds.aimConstraint( Items[-1] , tmp , wuo = Items[ ( len( Items ) / 2 ) ] , wut='object' ) 
  2427.            
  2428.         cmds.delete( tmp_point_cons )
  2429.         To_Move =  ChainLength( ( tmp_knee , tmp ) )
  2430.         cmds.setAttr( ( tmp_knee[0] + '.' + 'ty' ) , ( To_Move * ( Global_Scene_Size * .2 ) )  )    # go crazy all out on a scale.
  2431.         Pole_Position = cmds.xform( tmp_knee , query = True , t = True , ws = True)
  2432.         cmds.delete( tmp )
  2433.        
  2434.     return Pole_Position
  2435.  
  2436.    
  2437.  
  2438. def RigBox_IK_PoleFind( Items ):    # fed a list of items checks all children for the pole control.
  2439.     PoleFound = 'Not Found'
  2440.    
  2441.     for x in Items:
  2442.         Children = cmds.listRelatives( x , children = True )
  2443.         pass # print Children
  2444.         if Children is None:
  2445.             pass
  2446.         else:
  2447.             for Child in Children:
  2448.                 IsRigBox_Item = cmds.attributeQuery( 'RigBox_Guide_SystemType' , node =  Child  , ex=True )
  2449.                 if IsRigBox_Item is True: # is part of rigbox
  2450.                     IsIt_A_Pole = (RigBox_ReadSystemTypeAtr( Child )) == 'PoleV' # check if current item has polev as an option?
  2451.                     if IsIt_A_Pole is True:
  2452.                         PoleFound =  Child
  2453.                         print ( 'Found polevector::  ' + Child + ' in list of Items' )
  2454.                         print Items
  2455.                         break
  2456.                        
  2457.     return PoleFound
  2458.    
  2459. def RigBox_Guide_To_Rig_IKFK( Items )
  2460.     print 'ikfkwip'
  2461.    
  2462.     # RigBox_Guide_To_Rig_IK( Items )
  2463.     # pass # Start creating the copies of the guides for use as FK controllers..
  2464.     # for x in Items:
  2465.         # cmds.select( clear = True )
  2466.         # Original_Guide = x.replace( '_Jnt' , '' )
  2467.         # RigBox_ControlCreate( Original_Guide )   
  2468.    
  2469. def RigBox_Guide_To_Rig_Control( Items ):    # deals with items that arent ik or fk and arent a type of pin, but still need constraining up!
  2470.     for x in Items:
  2471.         print x
  2472.  
  2473.         Operation = []
  2474.        
  2475.         count = 0
  2476.         cmds.select( clear = True )
  2477.         cmds.select( x )       
  2478.         while count < 2:   
  2479.             cmds.pickWalk( direction='up' )
  2480.             Current_Parent = cmds.ls( selection = True , transforms = True )   
  2481.            
  2482.             All_GuidesFound = RigBox_FindAll( 'Guide' )
  2483.             TestItsAGuide = In_List_Test( Current_Parent[0] , All_GuidesFound )
  2484.             print x
  2485.             print TestItsAGuide
  2486.             print 'boob'
  2487.             if TestItsAGuide is True:
  2488.                 Operation =[ x , Current_Parent[0] ]
  2489.                 break
  2490.             count+=1
  2491.            
  2492.         if len( Operation ) is 2:
  2493.             print 'booombtastic'
  2494.             ItemToUse = [ None ]
  2495.             counter = 0
  2496.             while counter < 1:
  2497.  
  2498.                 TestControl = cmds.ls( ( Current_Parent[0] + '_Control' ) )
  2499.                 if len( TestControl ) > 0:
  2500.                     ItemToUse = TestControl
  2501.                     break  
  2502.  
  2503.                 TestControlFK = cmds.ls( ( Current_Parent[0] + '_Control_FK' ) )
  2504.                 if len( TestControlFK ) > 0:
  2505.                     ItemToUse = TestControlFK
  2506.                     break  
  2507.                    
  2508.  
  2509.                 TestJnt = cmds.ls( ( Current_Parent[0] + Suffix_Joints[0] ) )
  2510.                 if len( TestJnt ) > 0:
  2511.                     ItemToUse = TestJnt
  2512.                     break
  2513.  
  2514.                 counter+=1
  2515.                
  2516.             print ItemToUse    
  2517.             if len( ItemToUse ) is None :
  2518.                 pass
  2519.             else:
  2520.  
  2521.                 cmds.parentConstraint( ItemToUse[0] , ( x + '_Control_Grp' )  , mo = True )
  2522.  
  2523.  
  2524.            
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.                
  2536.    
  2537.    
  2538. def RigBox_Guide_To_Rig_FK( Items , Mode ):
  2539.     print 'fk wip'
  2540.  
  2541.  
  2542.     pass # constraining all fk joints found to there corresponding fk controls, making a check for the local variety too..
  2543.     for x in Items:
  2544.         Guide_Extra_Type = RigBox_ReadExtraTypeAtr( x )    
  2545.         if Guide_Extra_Type == 'Local':
  2546.             RigBox_Blend_2_Items( ( x + Suffix_Joints[2] ) , ( x + '_Control_Local_FK' ) , 'UseCons' , True )      
  2547.         else:
  2548.             RigBox_Blend_2_Items( ( x + Suffix_Joints[2] ) , ( x + '_Control_FK' ) , 'UseCons' , True )
  2549.        
  2550.     pass # Now to create the 4 way follow / dont follow Constraints setup
  2551.     for x in Items:    
  2552.         Control_Grp = ( x + '_Control_FK_Grp' )
  2553.         Control =  ( x + '_Control_FK' )
  2554.        
  2555.         cmds.pointConstraint( ( x + '_PinFollow' )  , Control_Grp , mo = False )
  2556.         cmds.pointConstraint( ( x + '_PinNoFollow' )  , Control_Grp , mo = False ) 
  2557.         cmds.orientConstraint( ( x + '_PinFollow' )  , Control_Grp , mo = False )
  2558.         cmds.orientConstraint( ( x + '_PinNoFollow' )  , Control_Grp , mo = False )    
  2559.  
  2560.         pass # Names to use for the fields../ channels
  2561.         cmds.addAttr( Control , shortName= Follow_Channel_Names[0] , attributeType='float' , min = 0.0 , max=1.0 )
  2562.         cmds.addAttr( Control , shortName= ( 'Rev_' + Follow_Channel_Names[0] ) , attributeType='float' , min = 0.0 , max=10.0 )
  2563.         cmds.addAttr( Control , shortName= Follow_Channel_Names[1] , attributeType='float' , min = 0.0 , max=1.0 )
  2564.         cmds.addAttr( Control , shortName= ( 'Rev_' + Follow_Channel_Names[1] ) , attributeType='float' , min = 0.0 , max=10.0 )       
  2565.        
  2566.         for chans in Follow_Channel_Names:
  2567.             cmds.setAttr( ( Control + '.' + chans ) ,  1 ) 
  2568.             cmds.setAttr( ( Control + '.' + chans ) , lock = False , channelBox = True )
  2569.             cmds.setAttr( ( Control + '.' + chans ) , keyable = True )
  2570.            
  2571.            
  2572.         Reverse_Node = cmds.shadingNode( 'reverse' , asUtility = True , n = ( Control + '_Rev_Node' ) )
  2573.         cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[0] ) , ( Reverse_Node + '.inputX' ) )     
  2574.         cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[1] ) , ( Reverse_Node + '.inputY' ) )             
  2575.        
  2576.         cmds.connectAttr( ( Reverse_Node + '.outputX' ) , ( Control + '.Rev_' +  Follow_Channel_Names[0] ) )               
  2577.         cmds.connectAttr( ( Reverse_Node + '.outputY' ) , ( Control + '.Rev_' +  Follow_Channel_Names[1] ) )       
  2578.        
  2579.         Cons_Name = cmds.pointConstraint( Control_Grp , query=True )   
  2580.         Cons_Targets = cmds.pointConstraint( Control_Grp , query=True , tl=True )              
  2581.        
  2582.         cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[0] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )             
  2583.         cmds.connectAttr( ( Control + '.Rev_' + Follow_Channel_Names[0] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' )   )                   
  2584.    
  2585.    
  2586.         Cons_Name = cmds.orientConstraint( Control_Grp , query=True )  
  2587.         Cons_Targets = cmds.orientConstraint( Control_Grp , query=True , tl=True )     
  2588.    
  2589.         cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[1] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )             
  2590.         cmds.connectAttr( ( Control + '.Rev_' + Follow_Channel_Names[1] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' )   )           
  2591.     pass #  4 way follow / dont follow Constraints setup     DONE!
  2592.    
  2593.    
  2594. pass # creating the controller duplication class below..
  2595. def Controller_Duplication( Name_To_Dupe , NewName ):
  2596.     global All_Controls_Made
  2597.    
  2598.     Controller_Duped = cmds.duplicate( Name_To_Dupe , name = NewName , rc = True , ic = False )
  2599.     RigBox_RemoveAllAtr( Controller_Duped[0] )
  2600.     # cmds.parent( Controller_Duped , 'Character_Rig_Controls' )
  2601.     cmds.select( Controller_Duped )
  2602.     cmds.select( Controller_Duped[0] , d = True)   
  2603.     cmds.delete()
  2604.     cmds.parent( Controller_Duped[0] , 'Character_Rig_Controls' )  
  2605.     All_Controls_Made.append( Controller_Duped[0] )
  2606.     return Controller_Duped[0]
  2607.  
  2608. def Controller_Vis( Item , Item_1 , Item_2 ):
  2609.     cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Item_2 + '.v' ) )     
  2610.     cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( Item_1 + '.v' ) ) 
  2611.  
  2612.        
  2613. def RigBox_ControlCreate( Guide )
  2614.  
  2615.     global Global_Local_Control_Size
  2616.     Size_To_Scale = [ Global_Local_Control_Size , Global_Local_Control_Size , Global_Local_Control_Size ]
  2617.  
  2618.     print ( 'creating the control objects before setting up..: ' + Guide )
  2619.     pass #first grab the details we need
  2620.     Guide_System_Type = RigBox_ReadSystemTypeAtr( Guide )
  2621.     Guide_Extra_Type = RigBox_ReadExtraTypeAtr( Guide )
  2622.  
  2623.     pass # Start creating the controller with correct options / setup.... takes into consideration the 'extras options'..
  2624.     cmds.select( clear = True )
  2625.    
  2626.  
  2627.    
  2628.     if Guide_System_Type == 'IKFK':
  2629.  
  2630.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
  2631.         RigBox_GrouperCtrls( New_Control_Item )
  2632.         cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )      
  2633.  
  2634.         cmds.select( clear = True )
  2635.         Tmp_Pivot = cmds.group( em = True , world = True )      #doesnt exhist, make it.
  2636.         tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )    
  2637.  
  2638.         pass # grab world transforms
  2639.         Guide_Trans = cmds.xform( Tmp_Pivot  , query=True , t=True , ws = True)
  2640.         pass # grab world rotations
  2641.         Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
  2642.        
  2643.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
  2644.         pass # set the pivot of the fk pivot!
  2645.         cmds.parent( New_Control_Item , Tmp_Pivot )
  2646.         cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
  2647.         cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space!
  2648.         cmds.parent( New_Control_Item , 'Character_Rig_Controls' ) 
  2649.         cmds.delete( Tmp_Pivot )
  2650.        
  2651.        
  2652.         RigBox_GrouperCtrls( New_Control_Item )            
  2653.         cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )      
  2654.    
  2655.         if Guide_Extra_Type == 'Local':
  2656.             pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
  2657.  
  2658.             cmds.select( clear = True )
  2659.             Tmp_Pivot = cmds.group( em = True )         #doesnt exhist, make it.
  2660.             tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )    
  2661.  
  2662.             pass # grab world transforms
  2663.             Guide_Trans = cmds.xform( Tmp_Pivot  , query=True , t=True , ws = True)
  2664.             pass # grab world rotations
  2665.             Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
  2666.            
  2667.             New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
  2668.             pass # set the pivot of the fk pivot!
  2669.             cmds.parent( New_Control_Item , Tmp_Pivot )
  2670.             cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
  2671.             cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space!
  2672.             cmds.parent( New_Control_Item , 'Character_Rig_Controls' ) 
  2673.             cmds.delete( Tmp_Pivot )
  2674.  
  2675.             cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2]  , New_Control_Item )
  2676.             RigBox_GrouperCtrls( New_Control_Item )
  2677.             cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )      
  2678.             RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_FK_Grp' ) , ( Guide + '_Control' + '_FK' ) , 'UseCons' , True )
  2679.  
  2680.            
  2681.             New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_IK' ) )
  2682.             cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
  2683.             RigBox_GrouperCtrls( New_Control_Item )
  2684.             cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )      
  2685.             RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_IK_Grp' ) , ( Guide + '_Control' + '_IK' ) , 'UseCons' , True )
  2686.  
  2687.            
  2688.     if Guide_System_Type == 'IK':
  2689.  
  2690.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
  2691.         RigBox_GrouperCtrls( New_Control_Item )
  2692.         cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )      
  2693.            
  2694.         if Guide_Extra_Type == 'Local':
  2695.             New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_IK' ) )
  2696.             cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
  2697.             RigBox_GrouperCtrls( New_Control_Item )
  2698.             RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_IK_Grp' ) , ( Guide + '_Control' + '_IK' ) , 'UseCons' , True )
  2699.             cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )      
  2700.  
  2701.            
  2702.     if Guide_System_Type == 'FK':
  2703.  
  2704.         cmds.select( clear = True )
  2705.         Tmp_Pivot = cmds.group( em = True )         #doesnt exhist, make it.
  2706.         tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )    
  2707.  
  2708.         pass # grab world transforms
  2709.         Guide_Trans = cmds.xform( Tmp_Pivot  , query=True , t=True , ws = True)
  2710.         pass # grab world rotations
  2711.         Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
  2712.        
  2713.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
  2714.         pass # set the pivot of the fk pivot!
  2715.         cmds.parent( New_Control_Item , Tmp_Pivot )
  2716.         cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
  2717.         cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space !
  2718.         cmds.parent( New_Control_Item , 'Character_Rig_Controls' ) 
  2719.         cmds.delete( Tmp_Pivot )
  2720.        
  2721.    
  2722.         pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
  2723.         RigBox_GrouperCtrls( New_Control_Item )
  2724.         cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )      
  2725.  
  2726.        
  2727.         if Guide_Extra_Type == 'Local':
  2728.  
  2729.             pass # grab world transforms
  2730.             Guide_Trans = cmds.xform( ( Guide + '_Local_Jnt' )  , query=True , t=True , ws = True)
  2731.             pass # grab world rotations
  2732.             Guide_Rots = cmds.xform( ( Guide + '_Local_Jnt' ) , query=True , ro=True , ws = True )
  2733.             New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
  2734.             pass # set the pivot of the fk pivot!
  2735.             cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space !
  2736.             cmds.parent( New_Control_Item , ( Guide + '_Local_Jnt' ) )
  2737.             cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
  2738.             cmds.parent( New_Control_Item , 'Character_Rig_Controls' ) 
  2739.        
  2740.             pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
  2741.             cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
  2742.             RigBox_GrouperCtrls( New_Control_Item )
  2743.             RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_FK_Grp' ) , ( Guide + '_Control' + '_FK' ) , 'UseCons' , True )
  2744.             cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )      
  2745.  
  2746.            
  2747.     if Guide_System_Type == '_':
  2748.  
  2749.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
  2750.         RigBox_GrouperCtrls( New_Control_Item )
  2751.            
  2752.     if Guide_System_Type == 'PoleV': # got to treat this like an ik object..
  2753.  
  2754.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
  2755.         RigBox_GrouperCtrls( New_Control_Item )
  2756.  
  2757.     if Guide_System_Type == 'Aim_Target':
  2758.  
  2759.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
  2760.         RigBox_GrouperCtrls( New_Control_Item )
  2761.        
  2762.     if Guide_System_Type == 'Aim_Affected':
  2763.  
  2764.         New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
  2765.         RigBox_GrouperCtrls( New_Control_Item )    
  2766.  
  2767.     global All_Controls_Made
  2768.     All_Controls_Made.append( New_Control_Item )   
  2769.     print New_Control_Item
  2770.     return New_Control_Item
  2771.        
  2772. def RigBox_PinCreator():   
  2773.     print '\n---[[[[[[[[[       Starting Pinning System         ]]]]]]]]]---'
  2774.     pass # create the groups..
  2775.     PinsFollow_Group = cmds.group( em = True , name = 'Character_Rig_Pins_Follow' , parent = 'Character_Rig_Pins' )         #doesnt exhist, make it.       
  2776.     PinsNoFollow_Group = cmds.group( em = True , name = 'Character_Rig_Pins_NoFollow' , parent = 'Character_Rig_Pins' )         #doesnt exhist, make it.   
  2777.  
  2778.     All_Guides = RigBox_FindAll( 'Guide' )
  2779.     for x in All_Guides:
  2780.         if '_Local' in x:
  2781.             pass
  2782.         else:
  2783.             Pin_Master = cmds.group( em = True , name = ( x + '_PinMaster' ) , parent = 'Character_Rig_Pins_Follow' )
  2784.             Pin_Follow = cmds.group( em = True , name = ( x + '_PinFollow' ) , parent = Pin_Master  )
  2785.  
  2786.             Pin_NoFollow = cmds.group( em = True , name = ( x + '_PinNoFollow' ) , parent = 'Character_Rig_Pins_NoFollow' )
  2787.  
  2788.             Test = cmds.ls( ( x + '_Local_Jnt' ) )
  2789.  
  2790.             if len( Test ) > 0:        
  2791.                 tmp1 = cmds.parentConstraint( ( x + '_Local_Jnt' ), Pin_Master , mo = False )      
  2792.             else:
  2793.                 tmp1 = cmds.parentConstraint(  x , Pin_Master , mo = False )
  2794.                
  2795.             cmds.delete( tmp1 )
  2796.                
  2797.             cmds.parentConstraint( Pin_Master , Pin_Follow , mo = False )          
  2798.            
  2799.             tmp1 = cmds.parentConstraint( Pin_Follow , Pin_NoFollow , mo = False )
  2800.             cmds.delete( tmp1 )
  2801.  
  2802.            
  2803.             RelativeToUse = ['']
  2804.             count = 0
  2805.             while count < 1:
  2806.  
  2807.                 TestGuide = cmds.ls( x )
  2808.                 if len( TestGuide ) > 0:
  2809.                     RelativeToUse[0] = TestGuide
  2810.                     break                  
  2811.  
  2812.                 TestJnt = cmds.ls( ( x + Suffix_Joints[0] ) )
  2813.                 if len( TestJnt ) > 0:
  2814.                     RelativeToUse[0] = TestJnt
  2815.                     break
  2816.  
  2817.                 count+=1
  2818.  
  2819.            
  2820.             FindParent_Guide = cmds.listRelatives( RelativeToUse[0] , parent = True )
  2821.             Test_Its_Guide = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node =  FindParent_Guide[0]  , ex=True )
  2822.             if Test_Its_Guide is False:
  2823.                 pass
  2824.             else:
  2825.                 Parent_Guide_System_Type = RigBox_ReadSystemTypeAtr( FindParent_Guide[0] ) # find the parents system type
  2826.                 Parent_Guide_Extra_Type = RigBox_ReadExtraTypeAtr( FindParent_Guide[0] )   
  2827.                 TestParent_Guide_Local_Type = ( Parent_Guide_Extra_Type is Extra_Types[1] ) # is the parent guide type a local?
  2828.                
  2829.                 pass #printing the known values!
  2830.                 print ( 'Pin system: \n' + 'Pinning: ' + x + '\n pin = ' + Pin_Master + '  to  ' + FindParent_Guide[0] + '\n type =' + Parent_Guide_System_Type + '\n' )
  2831.    
  2832.    
  2833.                 pass # new system mothaf**ker
  2834.                 Guide_System_Type = RigBox_ReadSystemTypeAtr( x ) # find the parents system type
  2835.                 Guide_Extra_Type = RigBox_ReadExtraTypeAtr( x )
  2836.                    
  2837.                 if Guide_System_Type == 'IK': #item is ik
  2838.                     if Parent_Guide_System_Type == 'FK':    #and parent is fk..
  2839.                         if TestParent_Guide_Local_Type is True: #and parent has local fk control... cons to that instead..
  2840.                             cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )
  2841.                    
  2842.                         if TestParent_Guide_Local_Type is False: #or not.. 
  2843.                             cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
  2844.                
  2845.                
  2846.                     if Parent_Guide_System_Type == '_':
  2847.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2848.                     if Parent_Guide_System_Type == 'PoleV':
  2849.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2850.                     if Parent_Guide_System_Type == 'Aim_Target':   
  2851.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2852.                     if Parent_Guide_System_Type == 'Aim_Affected'
  2853.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2854.                    
  2855.  
  2856.                
  2857.                
  2858.    
  2859.                 if Guide_System_Type == 'FK':  #item is fk only
  2860.                     if Parent_Guide_System_Type == 'FK':    #items parent is fk, just cons as normal (ignore local)
  2861.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
  2862.    
  2863.                     if Parent_Guide_System_Type == 'IK':    #items parent is fk, just cons as normal (ignore local)
  2864.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'IK' ) , Pin_Master , mo = True )
  2865.    
  2866.    
  2867.                     if Parent_Guide_System_Type == 'IKFK'#items parent is IKFK, need to switch between all cases..
  2868.                         RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[3] ) , ( FindParent_Guide[0] + '_Control_FK' ) , 'UseCons' , True )   
  2869.                         cmds.connectAttr( ( FindParent_Guide[0] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0]  ) )         
  2870.  
  2871.                        
  2872.                        
  2873.                        
  2874.                        
  2875.  
  2876.                     if Parent_Guide_System_Type == '_':
  2877.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2878.                     if Parent_Guide_System_Type == 'PoleV':
  2879.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2880.                     if Parent_Guide_System_Type == 'Aim_Target':   
  2881.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2882.                     if Parent_Guide_System_Type == 'Aim_Affected'
  2883.                         cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True ) 
  2884.    
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.                        
  2891.    
  2892.                 if Guide_System_Type == 'IKFK': #item is IKFK type..
  2893.                     if Parent_Guide_System_Type == 'FK':    #items parent is fk, just cons as normal (ignore local)
  2894.                         if TestParent_Guide_Local_Type is True: #and parent has local fk control... cons to that instead..
  2895.                             RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , ( FindParent_Guide[0] + '_Control_' + 'FK' ) , 'UseCons' , True )  
  2896.                             cmds.connectAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0]  ) )           
  2897.                         if TestParent_Guide_Local_Type is False:    #and parent has local fk control... cons to that instead..
  2898.                             cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
  2899.                        
  2900.                
  2901.                
  2902.                
  2903.                     if Parent_Guide_System_Type == 'IKFK'#items parent is IKFK, need to switch between all cases..
  2904.                         RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , ( FindParent_Guide[0] + Suffix_Joints[1] ) , 'UseCons' , True )
  2905.                         cmds.connectAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0]  ) )           
  2906.                
  2907.                
  2908.                
  2909.                
  2910.                
  2911.                     # if Parent_Guide_System_Type == 'FK':  #items parent is fk, just cons as normal (ignore local)
  2912.                         # if TestParent_Guide_Local_Type is True:   #and parent has local fk control... cons to that instead..
  2913.                             # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )
  2914.                    
  2915.                         # if TestParent_Guide_Local_Type is False: #or not..   
  2916.                             # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
  2917.                        
  2918.                        
  2919.                     # if Parent_Guide_System_Type == 'IK':  #items parent is IK, just cons as normal (ignore local)
  2920.                         # pass
  2921.                        
  2922.                    
  2923.  
  2924.                     # pass # create the blended pin!
  2925.                    
  2926.                    
  2927.                    
  2928.                    
  2929.                    
  2930.                
  2931.                     # if Guide_System_Type_Current == 'FK': #and parent is FK type..
  2932.                    
  2933.                    
  2934.                    
  2935.                    
  2936.                    
  2937.                         # RigBox_Blend_2_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , 'UseCons' , True )
  2938.                     # if Guide_System_Type_Current == 'IKFK':
  2939.                         # RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + '_Control_IK' ) , ( FindParent_Guide[0] + '_Control_FK' ) , 'UseCons' , True )
  2940.                         # cmds.connectAttr( ( FindParent_Guide[0] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0]  ) )           
  2941.                     # if Guide_System_Type_Current == 'IK':        
  2942.                         # RigBox_Blend_2_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , 'UseCons' , True )
  2943.  
  2944.                
  2945.                
  2946.                        
  2947.            
  2948.                 # if Parent_Guide_System_Type == 'IK':  #if the parent is an ik only type fk pins need to follow but other iks do not need to.
  2949.                     # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'IK' ) , Pin_Master , mo = True )
  2950.  
  2951.                
  2952.                 #need to break the ik and ikfk starts to follow the local control instead of the immediate parent.
  2953.  
  2954.                    
  2955.                 # if Parent_Guide_System_Type == 'FK':   # suspicious look at.
  2956.                     # pass # need to run a test for local fk control type!
  2957.                     # if TestParent_Guide_Local_Type is True:
  2958.                         # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )      # this is a specific hip test fix for characters that have a local control.                
  2959.                     # if TestParent_Guide_Local_Type is False:                 
  2960.                         # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )        # this is a specific hip test fix for characters that have a local control.                
  2961.                    
  2962.                    
  2963.                     # if TestGuide_Extra_Type is True:
  2964.                         # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )      # this is a specific hip test fix for characters that have a local control.                
  2965.                     # else:
  2966.                         # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )   
  2967.                    
  2968.                    
  2969.                 # if Guide_System_Type == '_': 
  2970.                     # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )   
  2971.                 # if Guide_System_Type == 'PoleV': 
  2972.                     # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )   
  2973.                 # if Guide_System_Type == 'Aim_Target':
  2974.                     # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )   
  2975.                 # if Guide_System_Type == 'Aim_Affected':  
  2976.                     # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )   
  2977.  
  2978.                 # print '---[[[[[[[[[       End Pinning System      ]]]]]]]]]---\n'
  2979.  
  2980.    
  2981.    
  2982. def RigBox_SpaceSwitching_list():
  2983.  
  2984.     Pin_Types_Found =[ [] ] * len( Pin_Types )
  2985.  
  2986.     count = 0
  2987.     for x in Pin_Types: # filling in the list with a list of the current options available.
  2988.         Pin_Types_Found[ count ] = [ Pin_Types[ count ] ]  
  2989.         count+=1   
  2990.        
  2991.     All_Guides = RigBox_FindAll( 'Guide' ) # grab all guides to begin with..
  2992.     for x in All_Guides:
  2993.         pass # grab each pin type.
  2994.         Type = RigBox_ReadPinTypeAtr( x )
  2995.         Type_Int = RigBox_List_To_Value( Pin_Types , Type )
  2996.        
  2997.         if Type_Int > 0:
  2998.             pass # fill in the list with the guide objects found..
  2999.             Pin_Types_Found[ Type_Int ].append( x )
  3000.  
  3001.     return Pin_Types_Found
  3002.  
  3003.            
  3004.            
  3005.            
  3006.            
  3007.    
  3008. def RigBox_SpaceSwitching():     # sets up the space switching constraints and attributes.
  3009.  
  3010.     Pin_Types_Found = RigBox_SpaceSwitching_list()
  3011.  
  3012.     for x in Pin_Types_Found:
  3013.    
  3014.         if len( x ) is 1:
  3015.             pass
  3016.         if len( x ) > 1: # something to constrain up?
  3017.             print  'Starting Space Switch Mode/Section:'
  3018.             Items =  x[1:]
  3019.             Type = x[0]
  3020.  
  3021.             if Type is Pin_Types[1]:
  3022.                 pass
  3023.             else:
  3024.                 for Item in Items:     
  3025.                     pass # is the item IK IKFK OR FK? fk shouldnt receive  space switching treatment.
  3026.                     Guide_System_Type = RigBox_ReadSystemTypeAtr( Item ) # find the parents system type
  3027.                     # if Guide_System_Type == '67':
  3028.                     if Guide_System_Type == 'FK':
  3029.                         pass
  3030.                
  3031.                     else:
  3032.                         FakeTests = [ 'boob' ]
  3033.                         GrpToBeControlled = ''
  3034.                         ControlToBeEdited = ''
  3035.                        
  3036.                         for FakeTest in FakeTests:
  3037.  
  3038.                            
  3039.                             TestExist = cmds.ls( ( Item + '_Control_Grp' ) )
  3040.                             if len( TestExist ) > 0:
  3041.                                 print TestExist
  3042.                                 GrpToBeControlled = TestExist
  3043.                                 ControlToBeEdited = ( Item + '_Control' )
  3044.                                 break
  3045.                            
  3046.                            
  3047.                             TestExist_IK = cmds.ls( ( Item + '_Control_IK_Grp' ) )
  3048.                             if len( TestExist_IK ) > 0:
  3049.                                 print TestExist_IK
  3050.                                 GrpToBeControlled = TestExist_IK
  3051.                                 ControlToBeEdited = ( Item + '_Control_IK' )
  3052.                                 break
  3053.                        
  3054.                             TestExist_FK = cmds.ls( ( Item + '_Control_FK_Grp' ) )
  3055.                             if len( TestExist_FK ) > 0:
  3056.                                 print TestExist_FK
  3057.                                 GrpToBeControlled = TestExist_FK   
  3058.                                 ControlToBeEdited = ( Item + '_Control_FK' )                               
  3059.                                 break
  3060.                        
  3061.                         print 'testinggee'
  3062.                         print Item
  3063.                         print GrpToBeControlled
  3064.                         print ControlToBeEdited
  3065.                         print '\n'
  3066.                        
  3067.                         Test = cmds.parentConstraint( GrpToBeControlled , q = True )
  3068.  
  3069.                         if Test is None:
  3070.                             pass # find the type in the global list to get the index value..
  3071.                             Type_Int = RigBox_List_To_Value( Pin_Types , Type )
  3072.                             Goals_To_Constrain_To = Pin_Type_Targets[ Type_Int ]
  3073.                             print '\n Space Switch Mode: '
  3074.                             print 'Item: ' + Item
  3075.                             print 'Being constrained to: '
  3076.                             print Goals_To_Constrain_To
  3077.                             print '\n'
  3078.  
  3079.                             Targets_Type_Found = []
  3080.                             Targets_Actually_Found = []                        
  3081.                            
  3082.                            
  3083.                             for Goal in Goals_To_Constrain_To:
  3084.                                 pass # print Goal
  3085.                                 test =  RigBox_List_To_Value( Pin_Types , Goal )
  3086.                                 if test is None:
  3087.                                     pass
  3088.                                 else:
  3089.                                    
  3090.                        
  3091.                                     tmp = Pin_Types_Found[ RigBox_List_To_Value( Pin_Types , Goal )]   
  3092.                                     print tmp
  3093.                                     Targets_Found = tmp[1:]
  3094.                                     for Targets in Targets_Found:
  3095.                                         pass # setup the constraints in order..
  3096.                                        
  3097.                                         Target = None
  3098.                                        
  3099.                                         Tmp = [ 'bla' ]
  3100.                                         for T in Tmp:
  3101.  
  3102.                                             Test_Control_IK = cmds.ls( ( Targets + '_Control_IK' ) )
  3103.                                             if Test_Control_IK is None:
  3104.                                                 pass
  3105.                                             if len( Test_Control_IK ) > 0:
  3106.                                                 Target = Test_Control_IK
  3107.                                                 break
  3108.  
  3109.                                            
  3110.                                             Test_Control = cmds.ls( ( Targets + '_Control' ) )                                         
  3111.                                             if Test_Control is None:
  3112.                                                 pass
  3113.                                             if len( Test_Control ) > 0:
  3114.                                                 Target = Test_Control
  3115.                                                 break
  3116.                                        
  3117.                                        
  3118.                                             Test_Control_FK = cmds.ls( ( Targets + '_Control_FK' ) )
  3119.                                             if Test_Control_FK is None:
  3120.                                                 pass
  3121.                                             if len( Test_Control_FK ) > 0:
  3122.                                                 Target = Test_Control_FK
  3123.                                                 break  
  3124.  
  3125.                                             pass # keep the joint search last, causes constraint loop if first.. need to fix!!!!   
  3126.                                             Test_Jnt = cmds.ls( ( Targets + Suffix_Joints[0] ) )
  3127.                                             if Test_Jnt is None:
  3128.                                                 pass
  3129.                                             if len( Test_Jnt ) > 0:
  3130.                                                 Target = Test_Jnt
  3131.                                                 break  
  3132.    
  3133.                                         if Target is None:
  3134.                                             break
  3135.                                         else:
  3136.                                             print Target
  3137.                                             print GrpToBeControlled
  3138.                                             cmds.parentConstraint( Target , GrpToBeControlled , w = 0.0 , mo = True )  
  3139.                                             Targets_Actually_Found.append( Target[0] )
  3140.                                             Targets_Type_Found.append( Targets )
  3141.        
  3142.                            
  3143.                             print ControlToBeEdited
  3144.                             pass # add the attribute here:
  3145.                             Parent_Types_Flat = Split_Char.join( Targets_Actually_Found )
  3146.                             cmds.addAttr(  ControlToBeEdited , shortName = ( 'Follow' ) , at = 'enum' , en = Parent_Types_Flat ) #add it to node
  3147.                             cmds.setAttr(  (  ControlToBeEdited + '.' + 'Follow' )   ) #set the correct value
  3148.                             cmds.setAttr(  (  ControlToBeEdited + '.' + 'Follow' ) , channelBox =True , keyable= True ) #add it to node
  3149.                             cmds.setAttr(  (  ControlToBeEdited + '.' + 'Follow' ) , keyable = True ) #add it to node  
  3150.                            
  3151.                            
  3152.                             pass # Now to setup the set driven keys..
  3153.                                
  3154.                             Name_Of_Cons_O = cmds.parentConstraint( GrpToBeControlled , query = True )          #gets the name of the constraint           
  3155.                             Cons_Targets = cmds.parentConstraint( GrpToBeControlled , query = True , tl = True )            #gets the name of the constraint           
  3156.  
  3157.                            
  3158.                             count = 0
  3159.                             for type_item in Targets_Actually_Found:
  3160.                                 cmds.setAttr(  ( ControlToBeEdited + '.' + 'Follow' ) , count ) #add it to node
  3161.                                
  3162.                                 Counters = 0
  3163.                                 for Targets in Cons_Targets:
  3164.                                     cmds.setAttr(  ( Name_Of_Cons_O + '.' + Targets + 'W' + str( Counters ) ) , 0 ) #add it to node
  3165.                                     Counters+=1            
  3166.                                 cmds.parentConstraint(  Cons_Targets[ count ] , GrpToBeControlled , e = True, w = 1.0 )
  3167.                                
  3168.                                 driver = ( ControlToBeEdited + '.' + 'Follow' )
  3169.                                
  3170.                                 counter = 0
  3171.                                 while counter < len( Targets_Actually_Found ):
  3172.  
  3173.                                     cmds.setDrivenKeyframe( ( Name_Of_Cons_O + '.' + Targets_Actually_Found[counter] + 'W' + str(counter) ) , cd= driver )
  3174.                                     counter+=1
  3175.                            
  3176.                                 count+=1
  3177.  
  3178.  
  3179.                             cmds.setAttr(  ( ControlToBeEdited + '.' + 'Follow' ) , 0 ) #add it to node
  3180.    
  3181.    
  3182.  
  3183. def RigBox_Frz_Vis_All():
  3184.     global All_Controls_Made
  3185.     print 'starting vis freeze all'
  3186.     print All_Controls_Made
  3187.     for controls in All_Controls_Made:     
  3188.         cmds.setAttr( ( controls + '.v' ) , lock = True , keyable = False , channelBox = False )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement