Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################################################################################
- # # Rig box 2015 : k flynn
- # # A simple / complex tool for creating multi faceted rigs with just a few clicks
- # # Full complex rigs in under an hour is the promise!
- # # While trying to maintain a simplicity of lego blocks
- # # enjoy
- # # Vers:v.12
- #######################################################################################
- # Features:
- # # Unity compatible scaling.
- # # Simple rig creation and editing (Just re-build from the guide objects) .
- # # simple layout in Maya for compatibility and editing
- #
- # # Follows the rotation order set by the guide objects for all items created there after..
- # # 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 )
- #
- # # eye ball / aim /
- # # FK Features:
- # # Local joint breaking behaviour as an option. ( under extra options as 'local' )
- # # Follow un-follow of rotation translation for each controller as a default option.
- # # FK Scale of each controller..
- #
- # #IK Features:
- #
- # # Local IK Control
- #
- # # TO IMPLEMENT SO FAR (in order):
- # # Implement new way of doing the join pivot locator? must be an easier way..
- # # IK Breakable elbow.
- # # Mirror setup easier
- # # Maya compatible Rig scaling ( uniform )
- # # foot roll / hand roll setup
- # # More Control variety
- # # IK Stretch
- # # Automatic colour / naming of controls
- # # Control bundles to save time
- # # Bendy / Spline IK
- # # Twist Joints / set-up
- # # IK FK Matching
- # # blink setup
- ########################################################################################
- # rules for tds to understand:
- # JOINTS: by default _Jnt , IK_MAIN_Jnt , IK_BREAK_Jnt and FK_Jnt. (all of Suffix_Joints below) joint chains will always be made..
- # ..this is for simplicity so the so the main chain will always have a ik fk attribute to edit.
- # need to break the processes down more, its getting too complicated now, too many special cases!
- # -- added the ability to set the colour of controls before creating them on the fly..
- # fixed the ik start controller having rotation still available despite being constrained, now rotations are locked
- # fixed visibility to now be locked on all controls.
- # fk controls should maybe only take the pivot of the joints? to avoid strangeness? --fixed!
- # 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..
- # also perhaps have a influenced by grandfather option? great for feathers/ tails.. etc
- # perhaps all joints should have ikfk by default?
- # also, perhaps all control pins above should link to a ik and fk pin of the parent...
- # ..while checking the current ikfk status of that joint and parent appropriately..
- #
- # mirror tool works better, now renames both control and local jnt and also does local rotation on localjnt.
- # footroll almost finished!
- # started on footroll
- # eye aim sorted, all eyeaim controls need to be in the parent hierachy of the eye (at least nested 2 parents up..)
- # recent fixes in order: recent progress:
- # ###### Local hip etc controls etc should control the ik pins! --fixed
- # Updated the constraining of none ik or fk item controls and joint heirechys
- # cleaned up grouping function slightly..
- # work finished on setting up ik items space switching!
- # started work on space switching, need to set-up how I will do constraints.
- # fixed pins for fk items not following the joint of the ikfk above instead of the controls (pulling fingers away from hand etc..)
- import maya.cmds as cmds
- Width_Height_Open = [ 250 , 50 ]
- Red_Btn_Col = ( .73 , .29 , .29 )
- Bright_Red_Btn_Col = ( 1 , .2 , .2 )
- Yel_Btn_Col = ( .84 , .76 , .31 )
- Grn_Btn_Col = ( .34 , .76 , .31 )
- Drk_Grey = [ .3 , .3 , .3 ]
- Lte_Grey = [ .47 , .45 , .45 ]
- pass # Attribute names: # Attribute names: # Attribute names: # Attribute names:
- Suffix_Joints = [ '_Jnt' , '_Jnt_IK_Break' , '_Jnt_FK' , '_Jnt_IK_Main' ] # joint chain names...
- IK_FK_Blend_Atr = [ 'IK_0_to_FK_1_Blend' , 'IK_FK_RevBlend' ]
- Follow_Channel_Names = [ 'Follow__Trans' , 'Follow__Rota' ]
- pass # Attribute names: # Attribute names: # Attribute names: # Attribute names:
- All_Controls_Made = []
- Global_Scene_Size = 25
- Global_Local_Control_Size = .9
- Global_Colour = 0
- MainGrp = 'Character'
- RigBox_All_Grps = [
- 'Character_Rig_Guide' ,
- 'Character_Rig_Mesh' ,
- 'Character_Rig_Controls' ,
- 'Character_Rig_BitsDoNotDelete' ,
- 'Character_Rig_Pins' ]
- RigBox_All_Grps_Vis = [ 0 , 1 , 1 , 0 , 0 ]
- RigBox_All_Grps_InheritTransform = [ 1 , 0 , 1 , 1 , 1 ]
- Joint_Grps = [
- 'Character_Rig_Joints' ,
- 'Character_Rig_Joints_FK' ,
- 'Character_Rig_Joints_IK_breakable' ,
- 'Character_Rig_Joints_IK_Main' ]
- Joint_Grps_Vis = [ 0 , 0 , 0 , 0 ]
- Joint_Grps_InheritTransform = [ 1 , 1 , 1 , 1 ]
- RigBox_All_Grps.extend( Joint_Grps )
- RigBox_All_Grps_Vis.extend( Joint_Grps_Vis )
- RigBox_All_Grps_InheritTransform.extend( Joint_Grps_InheritTransform )
- System_Types = [
- 'IK' ,
- 'FK' ,
- 'IKFK' ,
- '_' ,
- 'PoleV' ,
- 'Aim_Target' ,
- 'Aim_Affected' ] # the options used and added to the attributes..
- Pin_Types = [
- '_' ,
- 'World' ,
- 'Hip' ,
- 'Chest' ,
- 'L_Hand' ,
- 'L_Elbow_Pole' ,
- 'R_Hand' ,
- 'R_Elbow_Pole' ,
- 'Head' ,
- 'L_Foot' ,
- 'L_Knee_Pole' ,
- 'R_Foot' ,
- 'R_Knee_Pole' ,
- 'Misc' ,
- 'EyeAim' ] # values to declare what certain items could be..
- Pin_Type_Targets = [
- ['_' ] ,
- ['_' ] ,
- ['World' ] ,
- ['World' , 'Hip' ] ,
- ['World' , 'Hip' , 'Chest' , 'Head' ] ,
- ['World' , 'Hip' , 'Chest' , 'L_Hand' ] ,
- ['World' , 'Hip' , 'Chest' , 'Head' ] ,
- ['World' , 'Hip' , 'Chest' , 'R_Hand' ] ,
- ['World' , 'Hip' , 'Chest' , 'R_Hand' , 'L_Hand' ] ,
- ['World' , 'Hip' ] ,
- ['World' , 'Hip' , 'Chest' , 'L_Foot' ] ,
- ['World' , 'Hip' ] ,
- ['World' , 'Hip' , 'Chest' , 'R_Foot' ] ,
- ['World' , 'Hip' , 'Chest' , 'Head' , 'L_Hand' , 'L_Foot' , 'R_Hand' , 'R_Foot' ] ,
- ['World' , 'Hip' , 'Chest' , 'Head' ] ]
- Extra_Types = [
- '_' ,
- 'Local' ,
- 'Jiggle' ,
- 'Roll_Toe' ,
- 'Roll_Ball' ,
- 'Roll_Heel' ]
- Axis_Channels = [
- 'X+' ,
- 'Y+' ,
- 'Z+' ,
- 'X-' ,
- 'Y-' ,
- 'Z-' ,
- ]
- Extra_Options = [ 'IF_IK_allow_Breakable_IK_Setup' , 'IF_IK_allow_IK_Stretch_Opt' ]
- Extra_Options_Values = [ 'Yes' , 'No' ]
- Split_Char = ':'
- pass ## Biped Arm Simple Setup:
- BipedArm_Naming = [ 'L_Clavicle' , 'L_Shoulder' , 'L_Elbow' , 'L_Hand' ]
- BipedArm_Opts = [ 'FK' , 'IKFK' , 'IKFK' , 'IKFK' ]
- BipedArm_Pins = [ '_' , '_' , '_' , 'L_Hand' ]
- 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] ]
- pass ## Biped Leg Simple Setup:
- BipedLeg_Naming = [ 'L_Leg' , 'L_Knee' , 'L_Ankle' , 'L_Toes' ]
- BipedLeg_Opts = [ 'IKFK' , 'IKFK' , 'IKFK' , 'FK' ]
- BipedLeg_Pins = [ '_' , '_' , '_' , 'L_Foot' ]
- 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] ]
- pass ## Biped FK Back Simple Setup:
- BipedFKBack_Naming = [ 'Hip' , 'Back_01' , 'Back_02' , 'Chest' , 'Neck' , 'Head' ]
- BipedFKBack_Opts = [ 'FK' , 'FK' , 'FK' , 'FK' , 'FK' , 'FK' ]
- BipedFKBack_Pins = [ 'Hip' , '_' , '_' , 'Chest' , '_' , 'Head' ]
- 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] ]
- # BipedLeg_Naming = [ 'L_Clavicle' , 'L_Shoulder' , 'L_Knee' , 'L_Ankle' , 'L_Toe' ]
- # BipedLeg_Opts = [ 'IKFK' , 'IKFK' , 'IKFK' , 'IKFK' , 'L_Toe' ]
- # BipedLeg_Pins = [ '_' , '_' , '_' , 'L_Foot' , '_' ]
- # BipedLeg_Naming = [ 'L_Clavicle' , 'L_Shoulder' , 'L_Knee' , 'L_Ankle' , 'L_Toe' ]
- # BipedLeg_Opts = [ 'IKFK' , 'IKFK' , 'IKFK' , 'IKFK' , 'L_Toe' ]
- # BipedLeg_Pins = [ '_' , '_' , '_' , 'L_Foot' , '_' ]
- def Rig_Box_Win_cmd():
- Rig_Box_Win = "Rig_Box_Win"
- if cmds.window('Rig_Box_Win', exists=True):
- cmds.deleteUI('Rig_Box_Win', window=True)
- cmds.windowPref( 'Rig_Box_Win', remove=True )
- cmds.window( 'Rig_Box_Win' , rtf=True , toolbox=True , widthHeight = Width_Height_Open )
- cmds.rowColumnLayout( 'Rig_Box_MainWin' , numberOfColumns = 1 )
- cmds.text( label = '-: RigBox 2014 :-' , align = 'center' )
- 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()' )
- 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()')
- cmds.frameLayout( 'RigBox_LimbTypes' , label = 'Limb Types' , vis = True , cll = True , cl = True , parent = 'Rig_Box_MainWin' , width = Width_Height_Open[0] )
- cmds.rowColumnLayout( numberOfColumns = 3 )
- cmds.button( label = 'Biped Leg ' , command = 'RigBox_Build_BipedLeg()' , width = ( Width_Height_Open[0] / 3 ) )
- # cmds.button( label = 'Dog Leg ' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
- # cmds.button( label = 'Tentacle ' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Biped Arm ' , command = 'RigBox_Build_BipedArm()' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Biped FK Back' , command = 'RigBox_Build_BipedFKBack()' , width = ( Width_Height_Open[0] / 3 ) )
- # cmds.button( label = 'Simple Hand' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
- # cmds.button( label = 'Simple Head' , command = '' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.frameLayout( 'RigBox_ExtraTypes' , label = 'Extra Controls' , vis = True , cll = True , cl = True , parent = 'Rig_Box_MainWin' , width = Width_Height_Open[0] )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_1' , numberOfColumns = 3 , parent = 'RigBox_ExtraTypes' )
- cmds.button( label = 'Circle (lo) ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Circle_Low()' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Circle (hi) ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Circle_Hi()' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Ball obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Ball()' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Square obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_Square()' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.button( label = 'Pole Vector obj ' , parent = 'Rig_Box_MainCol_1' , command = 'RigBox_Guide_PoleV("Manual")' , width = ( Width_Height_Open[0] / 3 ) )
- cmds.text( label = '-: Additional :-' , align='center' , parent = 'Rig_Box_MainWin' )
- ##colour options
- cmds.frameLayout( 'Rig_Box_ColourOptsTab' , label = 'Extra Colour options' , vis = True , cll = True , cl = False , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_Colour' , numberOfColumns = 15, parent = 'Rig_Box_ColourOptsTab' )
- ##guide object options
- cmds.frameLayout( 'Rig_Box_AimOptsTab' , label = 'Extra Guide options' , vis = True , cll = True , cl = True , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_Axis' , numberOfColumns = 3 , parent = 'Rig_Box_AimOptsTab' )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_Mir' , numberOfColumns = 1 , parent = 'Rig_Box_AimOptsTab' )
- cmds.button( label = 'Move Selected PoleVector' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'Rigbox_IKPole_UIMover()' , width = ( Width_Height_Open[0] ) )
- cmds.button( label = 'Mirror Selected Item' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'RigBox_MirrorGuide()' , width = ( Width_Height_Open[0] ) )
- cmds.button( label = 'Freeze Guide Object' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Mir' , command = 'Rig_Box_FrzGrouperCtrls()' , width = ( Width_Height_Open[0] ) )
- 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] ) )
- cmds.button( label = 'Aim Axis' , command = 'RigBox_AimAxis()' , bgc = Yel_Btn_Col , parent = 'Rig_Box_MainCol_Axis')
- cmds.optionMenu( 'Axis_follow_Win_OptMenu' , label=' Axis To Aim:' , parent = 'Rig_Box_MainCol_Axis')
- for Axis in Axis_Channels:
- cmds.menuItem( label = Axis )
- 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' )
- ##rig building options
- cmds.frameLayout( 'Rig_Box_ExtraOptsTab' , label = 'Extra Rig options' , vis = True , cll = True , cl = True , parent='Rig_Box_MainWin' , width = Width_Height_Open[0] )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_Extras' , numberOfColumns = 1 , parent = 'Rig_Box_ExtraOptsTab' )
- 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.' )
- 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.' )
- 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.' )
- cmds.button( label = 'CleanUpdate_Guides' , bgc = Bright_Red_Btn_Col , parent = 'Rig_Box_MainCol_Extras' , command = 'RigBox_UpdateOldGuides()' , width = ( Width_Height_Open[0] ) )
- 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] ) )
- cmds.rowColumnLayout( 'Rig_Box_MainCol_End' , numberOfColumns=2 , parent = 'Rig_Box_MainWin' )
- cmds.button( label = 'Build Rig' , command = 'RigBox_Guide_To_Rig()' , width = ( Width_Height_Open[0] ) , parent = 'Rig_Box_MainCol_End')
- cmds.showWindow( 'Rig_Box_Win' )
- Rig_Box_Win_cmd()
- def RigBox_Build_BipedArm():
- RigBox_SceneSize()
- global Global_Scene_Size
- orig_Parent = RigBox_CurrentlySelected( True )
- cmds.select( clear = True )
- for i in range( 0 , len( BipedArm_Naming ) ):
- tmp_Xforms = BipedArm_Xforms[i]
- Item = RigBox_Guide_Piece( BipedArm_Naming[i] , 'Circle_Low' )
- cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )
- cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )
- RigBox_AddAllAtr( Item[0] , 'Misc' , BipedArm_Opts[i] , BipedArm_Pins[i] , '_' )
- def RigBox_Build_BipedLeg():
- RigBox_SceneSize()
- global Global_Scene_Size
- orig_Parent = RigBox_CurrentlySelected( True )
- cmds.select( clear = True )
- for i in range( 0 , len( BipedLeg_Naming ) ):
- tmp_Xforms = BipedLeg_Xforms[i]
- Item = RigBox_Guide_Piece( BipedLeg_Naming[i] , 'Circle_Low' )
- cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )
- cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )
- RigBox_AddAllAtr( Item[0] , 'Misc' , BipedLeg_Opts[i] , BipedLeg_Pins[i] , '_' )
- def RigBox_Build_BipedFKBack():
- RigBox_SceneSize()
- global Global_Scene_Size
- orig_Parent = RigBox_CurrentlySelected( True )
- cmds.select( clear = True )
- for i in range( 0 , len( BipedFKBack_Naming ) ):
- tmp_Xforms = BipedFKBack_Xforms[i]
- Item = RigBox_Guide_Piece( BipedFKBack_Naming[i] , 'Circle_Low' )
- cmds.xform( r = True , ro = ( tmp_Xforms[3] , tmp_Xforms[4] , tmp_Xforms[5] ) )
- cmds.xform( r = True , t = ( (tmp_Xforms[0] * Global_Scene_Size) , (tmp_Xforms[1] * Global_Scene_Size) , (tmp_Xforms[2] * Global_Scene_Size) ) )
- RigBox_AddAllAtr( Item[0] , 'Misc' , BipedFKBack_Opts[i] , BipedFKBack_Pins[i] , '_' )
- def RigBox_SceneSize():
- global Global_Scene_Size
- UnitFound = cmds.intSliderGrp( 'Rig_Box_UnitSize_Field' , q = True , v = True )
- CurrentSceneUnit = cmds.currentUnit( query=True, linear=True )
- if CurrentSceneUnit == 'mm':
- UnitFound = ( UnitFound * 10 )
- if CurrentSceneUnit == 'cm':
- UnitFound = UnitFound
- if CurrentSceneUnit == 'm':
- UnitFound = ( UnitFound * .01 )
- print ( 'Unit Used / found is ' + str(UnitFound) )
- Global_Scene_Size = UnitFound
- def RigBox_LocalConrolSize():
- global Global_Local_Control_Size
- UnitFound = cmds.floatSliderGrp( 'Rig_Box_LocalControlSize_Field' , q = True , v = True )
- print ( 'Local Control size is: ' + str(UnitFound) )
- Global_Local_Control_Size = UnitFound
- def RigBox_HideFinalJoints():
- global Joint_Grps_Vis
- tmp1 = cmds.checkBox( 'Rig_Box_Check_HideJoints' , q = True , v = True )
- Joint_Grps_Vis[0] = tmp1
- print ( 'changing visibility of final joints group. ' + str( tmp[0] ) )
- def Rig_Box_FrzGrouperCtrls():
- Seled = RigBox_CurrentlySelected( True )
- if Seled < 1:
- print 'Please select an item to place in a group'
- else:
- for x in Seled:
- pass #check has children guide objects?
- cmds.select( clear = True )
- Test_Children = cmds.listRelatives( x , children = True )
- cmds.select( Test_Children )
- ChildGuidesFound = RigBox_CurrentlySelected( True )
- if len( ChildGuidesFound ) < 1:
- pass #print ' no child guides found'
- else:
- print '\n child guides found, unparenting..'
- pass # is it a child of the world?
- cmds.select( clear = True )
- cmds.select( ChildGuidesFound )
- cmds.parent( world =True )
- Newgroup = cmds.group( em=True, name=(x+"_TmpGrp"))
- NewCons = cmds.parentConstraint( x , Newgroup , mo=False)
- cmds.select( NewCons , r=True)
- cmds.Delete();
- cmds.select( clear=True )
- cmds.select( x , r=True )
- cmds.pickWalk( direction='up' )
- xParent= cmds.ls( selection=True)
- cmds.parent(x, Newgroup)
- cmds.select( clear = True)
- cmds.select( x , r = True)
- cmds.makeIdentity( apply=True, t=1, r=1, s=1, n=2 ) #all 0
- if xParent > 0:
- if xParent[0] == x:
- cmds.parent( x , world = True )
- else:
- cmds.parent( x , xParent )
- else:
- pass
- cmds.delete( Newgroup )
- # print ChildrenGuideFound
- pass # reparent back up
- if len( ChildGuidesFound ) < 1:
- pass
- else:
- for Child in ChildGuidesFound:
- cmds.parent( Child , x )
- def RigBox_AimAxis(): #still needs tweaking to include an upvector of some kind!
- List_Sel = RigBox_CurrentlySelected( False )
- Axis_To_Use = cmds.optionMenu( 'Axis_follow_Win_OptMenu' ,q=True, v=True )
- Axis_Int = RigBox_List_To_Value( Axis_Channels , Axis_To_Use )
- Aim_Ints = [ (1,0,0) , (0,1,0) , (0,0,1) , (-1,0,0) , (0,-1,0) , (0,0,-1) ]
- count = 0
- while count < len(List_Sel):
- if ( count + 1 ) < len(List_Sel):
- aimCons = cmds.aimConstraint( List_Sel[count+1] , List_Sel[count] , aim = Aim_Ints[Axis_Int] , mo = False )
- cmds.delete( aimCons )
- else:
- AffectEnd = cmds.checkBox( 'Axis_follow_Win_Check' , q=True , v = True )
- if AffectEnd is True:
- OrienCons = cmds.orientConstraint( List_Sel[ count -1] , List_Sel[count] , mo = False )
- cmds.delete( OrienCons )
- count+=1
- def RigBox_ColourMenuWin():
- count = 1
- while count < 31:
- Colour = cmds.colorIndex(count, q=True)
- cmds.button( label = '' , command = 'RigBox_ColourMenuChange(' + str(count) + ')' , h = 17 , bgc = Colour , width = 16 , parent = 'Rig_Box_MainCol_Colour')
- count+=1
- RigBox_ColourMenuWin()
- def RigBox_ColourMenuChange( Colour ):
- global Global_Colour
- Global_Colour = Colour
- List_Sel = RigBox_CurrentlySelected( False )
- for x in List_Sel:
- ShapesFound = cmds.listRelatives( shapes =True )
- for Shapes in ShapesFound:
- cmds.setAttr ( ( Shapes + '.overrideEnabled' ) , 1 )
- cmds.setAttr ( ( Shapes + '.overrideColor' ) , Colour )
- print ( 'Setting Colour to: ' + str( Global_Colour ) )
- def RigBox_CurrentlySelected( CheckIfGuide ): #returns selected + error msgs
- Selected= []
- Selected = cmds.ls( selection=True , transforms = True )
- if Selected is None:
- return ''
- else:
- if CheckIfGuide is True:
- GuidesOnly = []
- for Possible_Guide in Selected:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = Possible_Guide , ex=True )
- if Test is True:
- GuidesOnly.append( Possible_Guide )
- if len(GuidesOnly) > 0:
- return GuidesOnly
- else:
- return ''
- else:
- return Selected
- def RigBox_LegalName( Name ):
- tmp = cmds.ls( selection = True )
- Name_Test_Group = cmds.group( em = True , name = Name )
- Name_Test_Group2 = cmds.group( em = True , name = Name_Test_Group )
- cmds.delete( Name_Test_Group , Name_Test_Group2 )
- Name = Name_Test_Group2
- if len( tmp ) < 1:
- pass
- else:
- cmds.select( tmp )
- return ( Name )
- def RigBox_MirrorGuide():
- tmp = RigBox_CurrentlySelected( True )
- for x in tmp:
- cmds.select(clear=True)
- NewJoint = cmds.joint ( n = ( x + '_Mirrored' ) )
- tmp_cons = cmds.parentConstraint( x , NewJoint , mo = False )
- cmds.delete( tmp_cons )
- NewJointRightSide = cmds.mirrorJoint( NewJoint , mirrorBehavior = True , myz = True , searchReplace = ( 'L_' , 'R_' ) )
- cmds.delete( NewJoint )
- if "L_" in x:
- Switch = [ 'L_' , 'R_' ]
- if "Left_" in x:
- Switch = [ 'Left_' , 'Right_' ]
- if "R_" in x:
- Switch = [ 'R_' , 'L_' ]
- if "Right_" in x:
- Switch = [ 'Right_' , 'Left_' ]
- NewName_OtherSide = x.replace( Switch[0] , Switch[1] )
- Item = cmds.duplicate( x , name = ( x.replace( Switch[0] , Switch[1] ) ) , rc = True , ic = False )
- cmds.select( Item[0] , hi =True )
- cmds.select( Item[0] , d = True )
- GuideChildren = RigBox_CurrentlySelected( True )
- print GuideChildren
- if len( GuideChildren ) < 1:
- pass
- else:
- cmds.delete( GuideChildren )
- MirrorGrp = cmds.group( em = True )
- cmds.parent( Item[0] , MirrorGrp )
- cmds.scale( -1, 1, 1 , MirrorGrp)
- tmp_cons = cmds.pointConstraint( NewJointRightSide , Item[0] , mo = False )
- cmds.delete( tmp_cons )
- tmp_cons = cmds.orientConstraint( NewJointRightSide , Item[0] , mo = False )
- cmds.delete( tmp_cons )
- cmds.parent( Item[0] , NewJointRightSide )
- cmds.select( clear = True )
- cmds.select( Item[0] )
- cmds.makeIdentity( apply = True, t=1, r=1, s=1, n=2 ) #all 0
- cmds.parent( Item[0] , world = True )
- cmds.delete( NewJointRightSide )
- cmds.delete( MirrorGrp )
- Test = cmds.ls( ( x + '_Local_Jnt' ) , type = 'transform' )
- if len( Test ) > 0:
- cmds.select( clear = True )
- cmds.select( Item[0] )
- cmds.pickWalk( d = 'down' )
- cmds.pickWalk( d = 'left' )
- cmds.rename( ( NewName_OtherSide + '_Local_Jnt' ) )
- Local_Rots = cmds.xform( ( x + '_Local_Jnt' ) , query = True , ro = True , os = True )
- cmds.xform( ( NewName_OtherSide + '_Local_Jnt' ) , ro = Local_Rots , os = True )
- def RigBox_DefaultGuideSetup_Start( Item ): # Create the Main Rig Guide Grp and continue! is ran each time a new guide piece is requested.
- Group_Test = cmds.ls( 'Character_Rig_Guide' , type= 'transform' )
- if len( Group_Test ) > 0:
- pass
- else: #exists
- Create_Group = cmds.group( em=True , name= 'Character_Rig_Guide' ) #doesnt exhist, make it.
- cmds.setAttr( ( 'Character_Rig_Guide' + '.v' ), 1 )
- cmds.setAttr( ( 'Character_Rig_Guide' + '.inheritsTransform' ), 1 )
- FindParent = cmds.listRelatives( Item , parent=True )
- if FindParent is None:
- cmds.parent( Item[0] , 'Character_Rig_Guide' )
- def RigBox_Guide_Circle_Low():
- print 'Creating a Circle Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Circle_Low' )
- RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
- def RigBox_Guide_Circle_Hi():
- print 'Creating a Circle Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Circle_Hi' )
- RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
- def RigBox_Guide_Ball():
- print 'Creating a Ball Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Misc' )
- RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
- def RigBox_Guide_Square():
- print 'Creating a Square Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('Misc1') ) , 'Square' )
- RigBox_AddAllAtr( Item[0] , 'Misc' , 'FK' , '_' , '_' )
- def RigBox_Guide_PoleV( type ):
- if type is 'Auto':
- tmp = cmds.ls( selection = True , flatten = True)
- if len( tmp ) < 1:
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('PoleV') ) , 'PoleV' )
- else:
- Item = RigBox_Guide_Piece( ( tmp[0] + '_Pole' ) , 'PoleV' )
- RigBox_AddAllAtr( Item[0] , 'PoleV' , 'PoleV' , '_' , '_' )
- return Item
- if type is 'Manual':
- tmp = cmds.ls( selection = True , flatten = True)
- if len( tmp ) < 2:
- print 'Creating a PoleV Control.. Move scale and rotate to where it needs to be and place in the hierachy of other guide items'
- else:
- print 'Creating a PoleV Control.. between the selected items..'
- World_Pos = RigBox_IK_PolePosition( tmp )
- if len(tmp) < 1:
- Item = RigBox_Guide_Piece( ( RigBox_LegalName('PoleV') ) , 'PoleV' )
- if len(tmp) > 0:
- cmds.select( clear = True )
- cmds.select( tmp[0] )
- Item = RigBox_Guide_Piece( ( tmp[0] + '_Pole' ) , 'PoleV' )
- RigBox_AddAllAtr( Item[0] , 'PoleV' , 'PoleV' , '_' , '_' )
- cmds.move( World_Pos[0] , World_Pos[1] , World_Pos[2] , Item )
- return Item
- # def RigBox_Guide_IKFK():
- # 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'
- # Item = RigBox_Guide_Piece( ( RigBox_LegalName('IKFK') ) , 'IKFK' )
- # RigBox_AddAllAtr( Item[0] , 'IKFK' , '_' , '_' , '_' )
- # return Item
- def RigBox_Guide_Hip():
- print 'wip'
- def RigBox_Guide_Prop():
- print 'wip'
- def RigBox_Guide_Back():
- print 'wip'
- def RigBox_Guide_Clav():
- print 'wip'
- def RigBox_Guide_Arm():
- print 'wip'
- def RigBox_Guide_Hand():
- print 'wip'
- def RigBox_Guide_Head():
- print 'wip'
- def RigBox_Guide_EyeAim():
- print 'wip'
- def RigBox_Guide_Leg():
- print 'wip'
- def RigBox_Guide_Foot():
- print 'wip'
- def RigBox_Guide_Main():
- print 'wip'
- print 'Creating a Main Control.. Move scale and rotate to where it needs to be and place guide items as its children'
- Item = RigBox_Guide_Piece( 'Character' , 'Main' )
- RigBox_AddAllAtr( Item , 'Main' , 6 , 1 , 0 )
- FindParent = cmds.listRelatives( Item , parent=True )
- if FindParent is None:
- pass
- else:
- cmds.parent( Item , world = True )
- cmds.move( 0 , 0 , 0 , Item )
- print Item
- GrabAllGuidesMade = RigBox_FindAll( 'Guide' )
- for x in GrabAllGuidesMade:
- if x == Item[0]:
- print ( 'Ignoring ' + x )
- else:
- FindParent = cmds.listRelatives( x , parent=True )
- if FindParent is None:
- print x
- print FindParent
- cmds.parent( x , Item )
- else:
- pass
- pass #Attribute setting reading etc go here..
- def RigBox_List_To_Value( List , ToFind ): # given a list to check, it spits back a number that matches
- pass # convert string to list
- Check_List_Is_String = isinstance( List , str)
- if Check_List_Is_String is True:
- print 'STRING DETECTED INSTEAD OF LIST, converting'
- Tmp_List = List.split( Split_Char )
- List = []
- List = List
- else:
- pass
- count = 0
- while count < len( List ):
- List_Item = List[ count ]
- Match_Test = ToFind == List_Item #may be a dodgy change from is to ==???
- if Match_Test is True:
- return count
- else:
- pass
- count+=1
- 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
- if Item == '':
- tmp = cmds.ls( selection=True , transforms = True )
- Item = tmp[0]
- print 'item false'
- else:
- pass
- cmds.addAttr( Item , shortName = ( 'RigBox_Guide_ControlType' ) , dt = "string" ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ControlType' ) , str( Controller_Vis_Type ) , type = "string" )
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ControlType' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ControlType' ) , keyable = True ) #add it to node
- System_Types_Flat = Split_Char.join( System_Types )
- cmds.addAttr( Item , shortName = ( 'RigBox_Guide_SystemType' ) , at = 'enum' , en = System_Types_Flat ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_SystemType' ) , ( RigBox_List_To_Value( System_Types , Sys_Type ) ) ) #set the correct value
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_SystemType' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_SystemType' ) , keyable = True ) #add it to node
- Pin_Types_Flat = Split_Char.join( Pin_Types )
- cmds.addAttr( Item , shortName = ( 'RigBox_Guide_PinType' ) , at = 'enum' , en = Pin_Types_Flat ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_PinType' ) , ( RigBox_List_To_Value( Pin_Types , Pin_Type ) ) ) #set the correct value
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_PinType' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_PinType' ) , keyable = True ) #add it to node
- Extra_Types_Flat = Split_Char.join( Extra_Types )
- cmds.addAttr( Item , shortName = ( 'RigBox_Guide_ExtraType' ) , at = 'enum' , en = Extra_Types_Flat ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ExtraType' ) , ( RigBox_List_To_Value( Extra_Types , Extra_Type ) ) ) #set the correct value
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ExtraType' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( Item + '.' + 'RigBox_Guide_ExtraType' ) , keyable = True ) #add it to node
- for opts in Extra_Options:
- Extra_Opts_Flat_Vals = Split_Char.join( Extra_Options_Values )
- cmds.addAttr( Item , shortName = ( opts ) , at = 'enum' , en = Extra_Opts_Flat_Vals ) #add it to node
- cmds.setAttr( ( Item + '.' + opts ) , ( RigBox_List_To_Value( Extra_Options_Values , Extra_Options_Values[1] ) ) ) #set the correct value
- cmds.setAttr( ( Item + '.' + opts ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( Item + '.' + opts ) , keyable = True ) #add it to node
- def RigBox_UpdateOldGuides(): # used to update guides done with older version of this script..
- All = RigBox_FindAll( 'Guide' )
- for x in All:
- sysType = RigBox_ReadSystemTypeAtr( x )
- pinType = RigBox_ReadPinTypeAtr( x )
- extraType = RigBox_ReadExtraTypeAtr( x )
- RigBox_RemoveAllAtr( x )
- RigBox_AddAllAtr( x , 'Misc' , sysType , pinType , extraType )
- def RigBox_RemoveAllAtrOnSel():
- AllSel = cmds.ls( selection = True )
- for x in AllSel:
- RigBox_RemoveAllAtr( x )
- def RigBox_RemoveAllAtr( Item ): #feed me the item to cleanup ..
- 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' ]
- for Atrs in AllAtrs:
- Test = cmds.attributeQuery( Atrs , node = Item , ex=True )
- if Test is True:
- cmds.deleteAttr( ( Item + '.' + Atrs ) ) #add it to node
- def RigBox_ReadControlTypeAtr( Item ): #feed me the guide item to get .. returns string.
- Exist = cmds.ls( Item )
- if len(Exist) < 1 :
- pass
- else:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = Item , ex=True )
- if Test is True:
- TypeFound = cmds.getAttr( ( Item + '.RigBox_Guide_ControlType' ) )
- return TypeFound # will be string
- def RigBox_ReadSystemTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
- Exist = cmds.ls( Item )
- if len(Exist) < 1 :
- pass
- else:
- Test = cmds.attributeQuery( 'RigBox_Guide_SystemType' , node = Item , ex=True )
- if Test is True:
- SystemTypeFound = cmds.getAttr( ( Item + '.RigBox_Guide_SystemType' ) ) # will return int
- return System_Types[ SystemTypeFound ]
- def RigBox_ReadPinTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
- Exist = cmds.ls( Item )
- if len(Exist) < 1 :
- pass
- else:
- Test = cmds.attributeQuery( 'RigBox_Guide_PinType' , node = Item , ex=True )
- if Test is True:
- PinTypeFound = cmds.getAttr( ( Item + '.RigBox_Guide_PinType' ) ) # will return int
- return Pin_Types[ PinTypeFound ]
- def RigBox_ReadExtraTypeAtr( Item ): #feed me the guide item to get .. returns item from list above
- Exist = cmds.ls( Item )
- if len(Exist) < 1 :
- pass
- else:
- Test = cmds.attributeQuery( 'RigBox_Guide_ExtraType' , node = Item , ex=True )
- if Test is True:
- ExtraTypeFound = cmds.getAttr( ( Item + '.RigBox_Guide_ExtraType' ) ) # will return int
- return Extra_Types[ ExtraTypeFound ]
- pass #Attribute setting reading etc go here.. all will feed back strings.
- def RigBox_Guide_Piece( GuidePieceName , GuidePieceType ): #all the common types of guide controls to be made go here..
- global Global_Scene_Size
- global Global_Colour
- MakeSureNameIsString = isinstance( GuidePieceName , str)
- if MakeSureNameIsString is True:
- pass
- else:
- GuidePieceName = ''.join(GuidePieceName)
- CurrentlySelected = RigBox_CurrentlySelected( 'True' )
- CreateLocal = True
- if GuidePieceType is 'Misc':
- tmp =cmds.circle( n = GuidePieceName , nr = ( 0 , 1 , 0 ) , r= ( Global_Scene_Size * 1) , d=3 , ch=False ) #in with the new!
- tmp2 = cmds.duplicate( tmp , rc = True , ic = False )
- cmds.rotate( 90 , 0 , 0 , tmp2 , r = True )
- tmp3 = cmds.duplicate( tmp , rc = True , ic = False )
- cmds.rotate( 0 , 0 , 90 , tmp3 , r = True )
- cmds.select( tmp2 , tmp3 )
- cmds.makeIdentity( apply=True, t=1, r=1, s=1, n=2 )
- cmds.select( hi = True )
- tmp_shapes = cmds.ls( selection = True , shapes=True )
- tmp_trans = cmds.ls( selection = True , transforms=True )
- cmds.select( clear=True )
- cmds.parent( tmp_shapes , tmp , r = True , s = True )
- cmds.delete( tmp_trans )
- if GuidePieceType is 'Main':
- tmp = cmds.circle( n = GuidePieceName , nr = ( 0 , 1 , 0 ) , r= ( Global_Scene_Size * 7) ,d=3,ch=False) #in with the new!
- cmds.select( clear=True )
- cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )
- cmds.scale( 1.415 , r=True , ocp=True )
- cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )
- cmds.scale( 1,1,1.415 , r=True , ocp=True )
- CreateLocal = False
- pass # cmds.sphere( -ch on -o on -po 0 -ax 0 1 0 -r 27.706748 -nsp 4 ;
- pass # disconnectAttr |nurbsSphere1|nurbsSphereShape1.instObjGroups[0] initialShadingGroup.dagSetMembers[1];
- pass # cmds.sphere( r= Unit ) #knee object
- if GuidePieceType is 'PoleV':
- tmp = cmds.sphere( name = GuidePieceName , r = ( Global_Scene_Size * .4 ) ) #knee object
- shape = cmds.listRelatives( tmp[0] , children = True , shapes = True )
- shadingGroup = cmds.listConnections( tmp[0] + '.instObjGroups')
- shadingGroup = cmds.listConnections( shape[0] + '.instObjGroups')
- # cmds.disconnectAttr( ( shape[0] + '.instObjGroups[0]' ) , ( shadingGroup[0] + '.dagSetMembers[0]' ) )
- CreateLocal = False
- if GuidePieceType is 'IKFK':
- tmp = cmds.sphere( name = GuidePieceName , r = ( Global_Scene_Size * .4 ) ) #knee object
- shape = cmds.listRelatives( tmp[0] , children = True , shapes = True )
- shadingGroup = cmds.listConnections( tmp[0] + '.instObjGroups')
- shadingGroup = cmds.listConnections( shape[0] + '.instObjGroups')
- # cmds.disconnectAttr( ( shape[0] + '.instObjGroups[0]' ) , ( shadingGroup[0] + '.dagSetMembers[0]' ) )
- RigBox_AddAllAtr( tmp[0] , 'IKFK' , '_' , '_' , '_' )
- cmds.addAttr( tmp , shortName = ( 'FK_IK_Switch' ) , attributeType='float' , min = 0.0 , max=1.0 )
- cmds.setAttr( ( tmp[0] + '.' + 'FK_IK_Switch' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( tmp[0] + '.' + 'FK_IK_Switch' ) , keyable = True ) #add it to node
- cmds.addAttr( tmp , shortName = ( 'FK_IK_TwistOveride' ) , attributeType='float' )
- cmds.setAttr( ( tmp[0] + '.' + 'FK_IK_TwistOveride' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( tmp[0] + '.' + 'FK_IK_TwistOveride' ) , keyable = True ) #add it to node
- CreateLocal = False
- if GuidePieceType is 'Circle_Low':
- tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 1 , ch = False ) #in with the new!
- if GuidePieceType is 'Circle_Hi':
- tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 3 , ch = False ) #in with the new!
- if GuidePieceType is 'Square':
- tmp = cmds.circle( n = GuidePieceName , nr=( 0 , 1 , 0 ) , r = ( Global_Scene_Size * 1) , d = 3 , ch = False ) #in with the new!
- cmds.select( clear=True )
- cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )
- cmds.scale( 1.415 , r=True , ocp=True )
- cmds.select( ( tmp[0] + '.cv[0]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[2]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[4]' ) , add=True )
- cmds.select( ( tmp[0] + '.cv[6]' ) , add=True )
- cmds.scale( 1,1,1.415 , r=True , ocp=True )
- if GuidePieceType is 'Twist':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Hip':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Prop':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Spine':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Chest':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Head':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Jaw':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Ear':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Nose':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Eyelid':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Cheek':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Mouth':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'EyeBrow':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'EyeAim':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Clav':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Shoulder':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Elbow':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Hand':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Finger':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Thigh':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Knee':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Ankle':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'FootRoll':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- if GuidePieceType is 'Toe':
- tmp = cmds.sphere( name = GuidePieceName , ssw = 0, esw = 180 , r = ( Global_Scene_Size * 1) ) #knee object
- # else:
- # print 'type not understood or exists for Guide Piece..'
- # tmp = ''
- if CreateLocal is True:
- pass #create the local point for the object asked..
- tmp_local = cmds.spaceLocator( n = ( GuidePieceName + '_Local_Jnt' ) )
- cmds.parent( tmp_local , tmp )
- cmds.rotate( 0 , 0 , 0 , tmp_local , a = True )
- cmds.move( 0 , 0 , 0 , tmp_local , ls = True )
- Channels = [ 'X' , 'Y' , 'Z' ]
- CurrentSceneUnit = cmds.currentUnit( query=True , linear=True )
- if CurrentSceneUnit == 'mm':
- UnitFound = 1000
- if CurrentSceneUnit == 'cm':
- UnitFound = 10
- if CurrentSceneUnit == 'm':
- UnitFound = 0.001
- for chan in Channels:
- cmds.setAttr( ( tmp_local[0] + '.' + 'localScale' + chan ) , UnitFound ) #add it to node
- RigBox_DefaultGuideSetup_Start( tmp )
- cmds.select( clear = True )
- cmds.select( GuidePieceName )
- RigBox_ColourMenuChange( Global_Colour )
- cmds.select( clear = True )
- pass #parenting stage, check if initial selected item was a guide piece, if so parent underneath, no exceptions.
- if len(CurrentlySelected) < 1:
- pass
- else:
- cmds.parent( tmp , CurrentlySelected )
- cmds.xform( tmp , t = (0,0,0) , ro = (0, 0, 0) , a = True )
- cmds.select( tmp )
- return tmp
- def RigBox_FindAll( type ): #run this to find every item in the scene created by the guide system.
- global All_Controls_Made
- AllScene = cmds.ls()
- All = []
- for x in AllScene:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = x , ex=True )
- if Test is True:
- All.append( x )
- else:
- pass
- if type is 'Joint':
- tmp = cmds.ls( ( '*' + Suffix_Joints[0] ) , type = 'joint' )
- All = []
- for x in tmp:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = x , ex=True )
- if Test is True:
- All.append( x )
- else:
- pass
- if type is 'Joint_FK':
- tmp = cmds.ls( ( '*' + Suffix_Joints[2] ) , type = 'joint' )
- All = []
- for x in tmp:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = x , ex=True )
- if Test is True:
- All.append( x )
- else:
- pass
- if type is 'Joint_IK':
- tmp = cmds.ls( ( '*' + Suffix_Joints[1] ) , type = 'joint' )
- All = []
- for x in tmp:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = x , ex=True )
- if Test is True:
- All.append( x )
- else:
- pass
- if type is 'Joint_IK_Extra':
- tmp = cmds.ls( ( '*' + Suffix_Joints[3] ) , type = 'joint' )
- All = []
- for x in tmp:
- Test = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = x , ex=True )
- if Test is True:
- All.append( x )
- else:
- pass
- if type is 'Guide':
- cmds.select( clear = True )
- cmds.select( All )
- tmp = cmds.ls( selection = True , type = 'joint' )
- cmds.select( clear = True )
- cmds.select( All )
- if len(tmp) < 1:
- pass
- else:
- cmds.select( tmp , d = True )
- All = cmds.ls( selection = True , type = 'transform' )
- else:
- pass
- cmds.select( clear = True )
- print ( '\n Found ' + str(len(All)) + ' ' + str(type) + ' items in Maya scene. \n')
- return All
- def RigBox_FindAncestor( Items ): # returns the grandfather items
- FinalAncestors = []
- tmp_list = set( Items )
- for Item in set( Items ):
- ChildrenOfItems = cmds.listRelatives( Item, c = True , type = 'transform' )
- if ChildrenOfItems is None:
- pass #broken deadend ignore
- else:
- for child in ChildrenOfItems:
- if child in tmp_list:
- tmp_list.remove( child )
- else:
- pass
- for x in tmp_list:
- FinalAncestors.append( x )
- return FinalAncestors
- def In_List_Test( Item , List ):
- for x in List:
- Test_Length = len( str(x) ) == len( str(Item) )
- if Test_Length is True:
- Test_StringMatch = str(x) == str(Item)
- if Test_StringMatch is True:
- print 'found'
- print x
- return True
- break
- pass # print ( 'match = ' + x + ' :goes with: ' + Item )
- pass # real meat of the rigging begins from here on.. all above are UI and incidentals.
- def RigBox_GrouperCtrls( x ): #pass the name, type of allowed movement on final, final name is returned and group above.
- Newgroup = cmds.group( em = True , name = ( x.replace( '_Grp' , '' ) + '_Grp' ) )
- NewCons = cmds.parentConstraint( x , Newgroup , mo = False )
- cmds.select( NewCons , r = True )
- cmds.Delete()
- cmds.select( clear = True )
- cmds.select( x , r = True )
- cmds.pickWalk( direction = 'up' )
- xParent= cmds.ls( selection = True)
- cmds.parent( x , Newgroup )
- if xParent > 0:
- if xParent[0] == x:
- pass #no parent..
- else:
- cmds.parent( Newgroup , xParent ) #has parent..
- else:
- pass
- cmds.makeIdentity( x , apply = True , t = 1 , r = 1 , s = 1 )
- 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
- pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################
- Test_Atr_Exist = cmds.attributeQuery( IK_FK_Blend_Atr[0] , node = Item , ex=True )
- if Test_Atr_Exist is True:
- pass
- else:
- cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[0] , attributeType = 'float' , min = 0.0 , max = 1.0 )
- cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[1] , attributeType = 'float' , min = 0.0 , max = 1.0 )
- cmds.setAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , lock = False , channelBox = True )
- cmds.setAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , keyable = True )
- Reverse_Node = cmds.shadingNode( 'reverse' , asUtility=True , n= ( Item + '_Rev_Node' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Reverse_Node + '.inputX' ) )
- cmds.connectAttr( ( Reverse_Node + '.outputX' ) , ( Item + '.' + IK_FK_Blend_Atr[1] ) )
- if type is 'UseCons':
- cmds.parentConstraint( Item_Goal_1 , Item , mo = Mo_Offset )
- cmds.parentConstraint( Item_Goal_2 , Item , mo = Mo_Offset )
- Cons_Name = cmds.parentConstraint( Item , query=True )
- Cons_Targets = cmds.parentConstraint( Item , query=True , tl=True )
- cmds.setAttr( ( Cons_Name + '.' + 'interpType' ) , 1)
- # setAttr "Misc11_Jnt_parentConstraint1.interpType" 0;
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' ) )
- Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Scale_Blend_Node + '.color2' ) )
- cmds.connectAttr( ( Item_Goal_2 + '.scale' ) , ( Scale_Blend_Node + '.color1' ) )
- cmds.connectAttr( ( Scale_Blend_Node + '.output' ) , ( Item + '.scale' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Scale_Blend_Node + '.blender' ) )
- if type is 'UseBlends':
- print ( 'blending on .. \n' + Item + '\n with both ' + Item_Goal_1 + ' \ ' + Item_Goal_2 )
- Trans_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Tran_Blend_Node' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.translate' ) , ( Trans_Blend_Node + '.color2' ) )
- cmds.connectAttr( ( Item_Goal_2 + '.translate' ) , ( Trans_Blend_Node + '.color1' ) )
- cmds.connectAttr( ( Trans_Blend_Node + '.output' ) , ( Item + '.translate' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Trans_Blend_Node + '.blender' ) )
- Rots_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Rot_Blend_Node' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.rotate' ) , ( Rots_Blend_Node + '.color2' ) )
- cmds.connectAttr( ( Item_Goal_2 + '.rotate' ) , ( Rots_Blend_Node + '.color1' ) )
- cmds.connectAttr( ( Rots_Blend_Node + '.output' ) , ( Item + '.rotate' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[0] ) , ( Rots_Blend_Node + '.blender' ) )
- Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Scale_Blend_Node + '.color2' ) )
- cmds.connectAttr( ( Item_Goal_2 + '.scale' ) , ( Scale_Blend_Node + '.color1' ) )
- cmds.connectAttr( ( Scale_Blend_Node + '.output' ) , ( Item + '.scale' ) )
- cmds.connectAttr( ( Item + '.' + IK_FK_Blend_Atr[1] ) , ( Scale_Blend_Node + '.blender' ) )
- pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################
- def RigBox_Blend_2_Items( Item , Item_Goal_1 , type , Mo_Offset ): #Blends the first item to the other directly.
- pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################
- Test_Atr_Exist = cmds.attributeQuery( IK_FK_Blend_Atr[0] , node = Item , ex=True )
- if Test_Atr_Exist is True:
- pass
- else:
- cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[0] , attributeType = 'float' , min = 0.0 , max = 1.0 )
- cmds.addAttr( Item , shortName = IK_FK_Blend_Atr[1] , attributeType = 'float' , min = 0.0 , max = 1.0 )
- if type is 'UseCons':
- cmds.parentConstraint( Item_Goal_1 , Item , mo = Mo_Offset )
- Scale_Blend_Node = cmds.shadingNode( 'blendColors' , asUtility = True , n = ( Item + '_IK_FK_Scale_Blend_Node' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Item + '.scale' ) )
- if type is 'UseBlends':
- cmds.connectAttr( ( Item_Goal_1 + '.translate' ) , ( Item + '.translate' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.rotate' ) , ( Item + '.rotate' ) )
- cmds.connectAttr( ( Item_Goal_1 + '.scale' ) , ( Item + '.scale' ) )
- pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################
- def RigBox_RigGrpCleanup(): # removes all the ik fk groups and any others its known, process is ran before joint creation etc.
- pass # need to remove all the old character rig controls if found?
- TestRebuild = cmds.checkBox( 'Rig_Box_Check_ReBuildJoints' , q = True , v = True )
- AllGrps_MinusGuide = RigBox_All_Grps[1:]
- for Grp in AllGrps_MinusGuide:
- TestExist = cmds.ls( Grp )
- if len( TestExist ) < 1:
- pass
- else:
- if Grp is Joint_Grps[0]:
- if TestRebuild is False:
- pass
- else:
- cmds.delete( Grp )
- else:
- cmds.delete( Grp )
- def RigBox_RigGrpCreate(): # create all groups before working.
- pass # need to remove all the old character rig controls if found?
- TestMain = cmds.ls( MainGrp )
- if len( TestMain ) < 1:
- cmds.group( em = True , name = MainGrp ) #doesnt exhist, make it.
- cmds.parent( RigBox_All_Grps[0] , MainGrp )
- AllGrps_MinusGuide = RigBox_All_Grps
- AllGrps_MinusGuide_Vis = RigBox_All_Grps_Vis
- AllGrps_MinusGuide_InheritTransform = RigBox_All_Grps_InheritTransform
- count = 0
- for Grp in AllGrps_MinusGuide:
- TestExist = cmds.ls( Grp , type= 'transform' )
- if len( TestExist ) < 1:
- Controls_Group = cmds.group( em = True , name = Grp , parent = MainGrp ) #doesnt exhist, make it.
- cmds.setAttr( ( Grp + '.v' ) , AllGrps_MinusGuide_Vis[ count ] )
- cmds.setAttr( ( Grp + '.inheritsTransform' ) , AllGrps_MinusGuide_InheritTransform[ count ] )
- count+=1
- #set vis of group guide to 0
- cmds.setAttr( ( RigBox_All_Grps[0] + '.v' ) , 0 )
- #set vis of character joints
- Check_Vis = cmds.checkBox( 'Rig_Box_Check_HideJoints' , q = True , v = True )
- cmds.setAttr( ( Joint_Grps[0] + '.v' ) , Check_Vis )
- grpParent = cmds.listRelatives( RigBox_All_Grps[0] , parent=True )
- if grpParent is None: #has no parent
- cmds.parent( RigBox_All_Grps[0] , MainGrp )
- else:
- if len(grpParent) > 0: #has no parent
- print grpParent
- Test = grpParent[0] == MainGrp
- print Test
- if Test is False:
- cmds.parent( RigBox_All_Grps[0] , MainGrp )
- def RigBox_JointChainCreator(): # Creates all the Joints FK and IK and blending / scale.
- pass #create the joints system for ik fk etc!
- AllItemGuides = RigBox_FindAll( 'Guide' )
- All_To_Be_Made = []
- for x in AllItemGuides: #create all the joints in correct position of world.
- Test_Is_Joint_Wanted = RigBox_ReadSystemTypeAtr( x )
- if Test_Is_Joint_Wanted is 'IK':
- All_To_Be_Made.append( x )
- if Test_Is_Joint_Wanted is 'FK':
- All_To_Be_Made.append( x )
- if Test_Is_Joint_Wanted is 'IKFK':
- All_To_Be_Made.append( x )
- if Test_Is_Joint_Wanted is '_':
- print ( 'No joint being made for ' + x + ' as requested \n')
- if Test_Is_Joint_Wanted is 'Aim_Affected': # treated as '_'
- print ( 'No joint being made for ' + x + ' as requested \n')
- if Test_Is_Joint_Wanted is 'Aim_Target': # treated as '_'
- print ( 'No joint being made for ' + x + ' as requested \n')
- if Test_Is_Joint_Wanted is 'PoleV': # treated as '_'
- print ( 'No joint being made for ' + x + ' as requested \n')
- for x in All_To_Be_Made:
- cmds.select( clear = True )
- Guide_Trans = cmds.xform( ( x + '_Local_Jnt' ) , query=True , t=True , ws = True)
- Guide_Rots = cmds.xform( ( x + '_Local_Jnt' ) , query=True , ro=True , ws = True )
- Guide_Scale = cmds.xform( x , query=True , s=True , r=True )
- Guide_RotOrder = cmds.getAttr( ( x + '.' + 'rotateOrder') )
- pass #always check if something exists? if so delete and start over.. no exceptions.
- for Suffix_Found in Suffix_Joints:
- cmds.select( clear = True )
- NewJoint = cmds.joint ( n = ( x + Suffix_Found ) )
- cmds.select( clear = True )
- RigBox_AddAllAtr( NewJoint , ( RigBox_ReadControlTypeAtr(x)) , (RigBox_ReadSystemTypeAtr(x)) , (RigBox_ReadPinTypeAtr(x)) , (RigBox_ReadExtraTypeAtr(x)) )
- tmp1 = cmds.parentConstraint( ( x + '_Local_Jnt' ) , NewJoint , mo = False )
- cmds.delete( tmp1 )
- cmds.setAttr( ( NewJoint + '.' + 'rotateOrder') , Guide_RotOrder )
- pass #Unity style joint scaling?
- UnityScale = cmds.checkBox( 'Rig_Box_Check_UnityScale' , query=True , v=True )
- if UnityScale is True:
- cmds.setAttr( ( NewJoint + '.segmentScaleCompensate' ) , 0 )
- cmds.setAttr( ( NewJoint + '.ssc' ) , lock=True )
- else:
- pass
- for atr in IK_FK_Blend_Atr:
- Joint = ( x + Suffix_Joints[0] )
- cmds.addAttr( Joint , shortName = atr , attributeType = 'float' , min = 0.0 , max = 1.0 )
- cmds.setAttr( ( Joint + '.' + atr ) , lock = False , channelBox = True )
- cmds.setAttr( ( Joint + '.' + atr ) , keyable = True )
- # pass # parenting section. Find the joint above given all circumstances.
- for Guide in All_To_Be_Made:
- FindParent = []
- count = 0
- cmds.select( clear = True )
- cmds.select( Guide )
- while count < 2:
- cmds.pickWalk( direction='up' )
- Current_Parent = cmds.ls( selection = True , transforms = True )
- Parent_Legal = In_List_Test( Current_Parent[0] , All_To_Be_Made )
- if Parent_Legal is True:
- print 'parent found for:'
- print Guide
- FindParent = Current_Parent
- print FindParent
- break
- count+=1
- if len( FindParent ) < 1:
- pass
- else:
- print ( str(Guide) + ' is to be the child of: \n' )
- print ( str(FindParent) + '\n' )
- for Suffix_Found in Suffix_Joints:
- Joint_Legal_Parent = cmds.ls( ( FindParent[0] + Suffix_Found ) )
- if len( Joint_Legal_Parent ) is 1:
- cmds.parent( ( Guide + Suffix_Found ) , ( FindParent[0] + Suffix_Found ) )
- else:
- pass
- for Guide in All_To_Be_Made:
- for Suffix_Found in Suffix_Joints:
- cmds.joint ( ( Guide + Suffix_Found ) , edit = True , setPreferredAngles = True , children= True)
- All_Joints = RigBox_FindAll( 'Joint' )
- All_Joints_FK = RigBox_FindAll( 'Joint_FK' )
- All_Joints_IK = RigBox_FindAll( 'Joint_IK' )
- All_Joints_IK_Extra = RigBox_FindAll( 'Joint_IK_Extra' )
- All_Joints_ParentsFound = RigBox_FindAncestor( All_Joints )
- if len( All_Joints_ParentsFound ) < 1:
- pass
- else:
- cmds.parent( All_Joints_ParentsFound , Joint_Grps[0] , )
- All_Joints_FK_ParentsFound = RigBox_FindAncestor( All_Joints_FK )
- if len( All_Joints_FK_ParentsFound ) < 1:
- pass
- else:
- cmds.parent( All_Joints_FK_ParentsFound , Joint_Grps[1] , )
- All_Joints_IK_ParentsFound = RigBox_FindAncestor( All_Joints_IK )
- if len( All_Joints_IK_ParentsFound ) < 1:
- pass
- else:
- cmds.parent( All_Joints_IK_ParentsFound , Joint_Grps[2] )
- All_Joints_IK_Extra_ParentsFound = RigBox_FindAncestor( All_Joints_IK_Extra )
- if len( All_Joints_IK_Extra_ParentsFound ) < 1:
- pass
- else:
- cmds.parent( All_Joints_IK_Extra_ParentsFound , Joint_Grps[3] )
- pass # Joints are now into the correct group..
- print 'Joints are now into the correct group.. \n'
- pass ############### SETTIING UP BLENDING SCEHEME HERE FOR IKFK ETC!##########################
- for x in All_To_Be_Made:
- Test_Is_Joint_IKFK = RigBox_ReadSystemTypeAtr( x )
- RigBox_Blend_3_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False )
- if Test_Is_Joint_IKFK == 'IKFK':
- cmds.setAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , 1 ) # set up as fk default..
- pass # RigBox_Blend_3_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False )
- if Test_Is_Joint_IKFK == 'IK':
- cmds.setAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , 1 )
- pass # RigBox_Blend_2_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[1] ) , 'UseCons' , False )
- if Test_Is_Joint_IKFK == 'FK':
- cmds.setAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , 0 ) # set up as fk default..
- pass # RigBox_Blend_2_Items( ( x + Suffix_Joints[0] ) , ( x + Suffix_Joints[2] ) , 'UseCons' , False )
- def RigBox_Guide_To_Rig(): # starts the process of converting the guide items to a rig.
- global All_Controls_Made
- All_Controls_Made = []
- IK = []
- IKFK = []
- FK = []
- Control = []
- PoleV = []
- Aim_Target = []
- Aim_Affected = []
- All_Guides = RigBox_FindAll( 'Guide' )
- if len(All_Guides) < 1:
- print 'No Rig_Box_Joints found in the scene?'
- else:
- cmds.select( clear = True) #begin the freezing of all guide objects!
- cmds.select( All_Guides )
- Rig_Box_FrzGrouperCtrls()
- RigBox_RigGrpCleanup() # cleaning up scene groups before working.
- RigBox_RigGrpCreate() # create all groups before working.
- RigBox_JointChainCreator() # create the ik fk and ikfk and binding up for all joints in the scene
- cmds.select( clear = True) #begin the freezing of all guide objects!
- for x in All_Guides:
- RigBox_ControlCreate( x )
- Guide_System_Type = RigBox_ReadSystemTypeAtr( x )
- if Guide_System_Type == 'IKFK':
- IKFK.append( x )
- if Guide_System_Type == 'IK':
- IK.append( x )
- if Guide_System_Type == 'FK':
- FK.append( x )
- if Guide_System_Type == '_':
- TestPinType = RigBox_ReadPinTypeAtr( x )
- if TestPinType == '_':
- Control.append( x )
- if Guide_System_Type == 'PoleV':
- PoleV.append( x )
- if Guide_System_Type == 'Aim_Target':
- Aim_Target.append( x )
- if Guide_System_Type == 'Aim_Affected':
- Aim_Affected.append( x )
- RigBox_PinCreator()
- if len( IK ) > 0:
- RigBox_Guide_To_Rig_IK( IK , 'IK' )
- if len( IKFK ) > 0:
- RigBox_Guide_To_Rig_FK( IKFK , 'IKFK' )
- RigBox_Guide_To_Rig_IK( IKFK , 'IKFK' )
- if len( FK ) > 0:
- RigBox_Guide_To_Rig_FK( FK , 'FK' )
- if len( Control ) > 0:
- RigBox_Guide_To_Rig_Control( Control )
- if len( Aim_Affected ) > 0:
- RigBox_Guide_To_Rig_AimAffected( Aim_Affected )
- RigBox_SpaceSwitching() # set up the space switching if any are found..
- RigBox_Frz_Vis_All() # freezes visibility on all pieces made..
- def RigBox_Guide_To_Rig_AimAffected( Items ): # used for setting up look at / aim at type constraints, eg eyes?!
- RigBox_Guide_To_Rig_Control( Items )
- print '\n Starting EyeAim Search process...'
- for Item in Items:
- Operation = None
- count = 0
- cmds.select( clear = True )
- cmds.select( Item )
- cmds.pickWalk( direction='up' )
- cmds.pickWalk( direction='up' )
- Current_Parent = cmds.ls( selection = True , transforms = True )
- PossibleEyeAimList = cmds.listRelatives( Current_Parent[0] , c = True , type = 'transform' , ad = True )
- for PossibleEye in PossibleEyeAimList:
- pass # see if its a EyeAim type?
- TestPinType = RigBox_ReadPinTypeAtr( PossibleEye )
- if TestPinType == 'EyeAim':
- Operation = PossibleEye
- break
- if Operation is None:
- pass
- else:
- print '\n'
- print ( Item + ' Is being aim targetted at:' )
- print Operation
- print '\n'
- cmds.aimConstraint( ( Operation + '_Control' ) , ( Item + '_Control' ) , aim = [ 0 , 1 , 0 ] , mo = True )
- def RigBox_Guide_To_Rig_RollControl( Items ): # given multiple lists eg [ [big list 1] , [big list 2 etc] ] will create the footroll / handroll setup..
- for Set in Items:
- print 'Starting Reverse foot / hand roll setup:'
- print Set
- print '\n'
- pass # check if is set.
- MakeSureSetIsNotString = isinstance( Set , list)
- if MakeSureSetIsNotString is False:
- print '\n foot roll possible issue'
- print Set
- print 'above Items are all that have been supplied. \n'
- tmp = [ Set ]
- Set = tmp
- Roll_Toe = None
- Roll_Toe_IK_Control = None # fk version wont exist due to the nature of ik..
- Roll_Ball = None
- Roll_Ball_FK_Control = None
- Roll_Ball_IK_Control = None
- ##
- Roll_Heel = None
- Roll_Heel_FK_Control = ( Set[-2] + '_Control_FK' )
- Roll_Heel_IK_Control = ( Set[-2] + '_Control_IK' )
- Roll_HeelRev_IK_Control = None
- for Item in Set: # find and place in correct list the types..
- pass # first sort blend remaining joints!
- TestExtraType = RigBox_ReadExtraTypeAtr( Item )
- if TestExtraType is not None:
- if 'Roll' in TestExtraType:
- Connected = cmds.listConnections( ( Item + Suffix_Joints[1] + '.translate' ) , destination = True)
- TestList = In_List_Test( ( Item + Suffix_Joints[3] ) , Connected )
- if TestList is not True:
- print ( 'blending ' + ( Item + Suffix_Joints[1] + '.t' ) + ' ' + ( Item + Suffix_Joints[3] + '.t' ) )
- RigBox_Blend_2_Items( ( Item + Suffix_Joints[1] ) , ( Item + Suffix_Joints[3] ) , 'UseBlends' , False )
- cmds.connectAttr( ( Set[-2] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) )
- for Item in Set: # find and place in correct list the types..
- FindExtraType = RigBox_ReadExtraTypeAtr( Item )
- if FindExtraType == 'Roll_Toe':
- Search = 'RollToe'
- FullName = ( Item + '_' + Search )
- pass # creating roll toe control that will control the entire foot reverse.
- Roll_Toe = Item
- cmds.select( clear = True )
- tmp = RigBox_Guide_PoleV('Auto') # create the guide version
- tmp5 = cmds.duplicate( tmp , name = FullName , rc = True )
- tmp2 = cmds.parentConstraint( ( Roll_Toe + '_Local_Jnt' ) , tmp5 , mo = False )
- cmds.delete( tmp )
- cmds.delete( tmp2 )
- Roll_Toe_IK_Control = RigBox_ControlCreate( FullName ) # create the real controller version
- cmds.delete( tmp5 )
- cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_Toe_IK_Control + '.v' ) )
- if FindExtraType == 'Roll_Ball': # declaring what controls the heel ik, and also creating the control that will affect the ball -> toe
- Roll_Ball = Item
- New_IK_ControlGrp = cmds.duplicate( ( Item + '_Control_FK_Grp' ) , name = ( Item + '_Control_IK_Grp' ) , rc = True )
- RigBox_RemoveAllAtr( New_IK_ControlGrp[0] )
- Roll_Ball_IK_Control = cmds.rename( New_IK_ControlGrp[1] , ( Item + '_Control_IK' ) )
- cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_Ball_IK_Control + '.v' ) )
- if FindExtraType == 'Roll_Heel':
- Search = 'RollHeel'
- Roll_Heel = Item
- Target = None
- if Roll_Ball is not None:
- FullName = ( Item + '_' + Search )
- tmp = RigBox_Guide_PoleV('Auto') # create the guide version
- tmp2 = cmds.parentConstraint( Roll_Ball , tmp[0] , mo = False )
- cmds.delete( tmp2 )
- tmp3 = cmds.rename( tmp[0] , FullName )
- Roll_HeelRev_IK_Control = RigBox_ControlCreate( FullName ) # create the real controller version
- cmds.delete( tmp3 )
- cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Roll_HeelRev_IK_Control + '.v' ) )
- if Roll_Toe is None:
- if Roll_Ball is None:
- if Roll_Heel is None:
- break
- pass # now to determine the type of roll we can do?
- ToeBall = False
- BallHeel = False
- ToeHeel = False
- Type = 0
- if Roll_Toe is not None:
- if Roll_Ball is not None:
- ToeBall = True
- Type +=1
- if Roll_Ball is not None:
- if Roll_Heel is not None:
- BallHeel = True
- Type +=1
- if Roll_Toe is not None:
- if Roll_Heel is not None:
- ToeHeel = True
- Type +=1
- pass # setting up IK Handles
- ToeBall_Handle = None
- BallHeel_Handle = None
- ToeHeel_Handle = None
- Heel_Handle = ( Set[-1] + '_Handle_IK' )
- pass # now break the original ik constraint on the heel handle.
- Heel_IK_HandleCons = cmds.parentConstraint( Heel_Handle , q = True )
- if len( Heel_IK_HandleCons ) is not None:
- cmds.delete( Heel_IK_HandleCons )
- if Type is 3: # full foot version?
- if ToeBall is True:
- 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
- ToeBall_Handle = Handle_Main[0]
- cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
- if BallHeel is True:
- 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
- BallHeel_Handle = Handle_Main[0]
- cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
- Ball_to_HeelCons = cmds.parentConstraint( Roll_HeelRev_IK_Control , Heel_Handle , mo = True )
- Heel_to_BallCons = cmds.parentConstraint( Roll_Ball_IK_Control , BallHeel_Handle , mo = True )
- Heel_to_BallCons = cmds.parentConstraint( Roll_Ball_IK_Control , ToeBall_Handle , mo = True )
- RollToe_Cons = cmds.parentConstraint( Roll_Toe_IK_Control , (Roll_Ball_IK_Control + '_Grp' ) , mo = True )
- RollToe_Cons = cmds.parentConstraint( Roll_Toe_IK_Control , ( Roll_HeelRev_IK_Control + '_Grp' ) , mo = True )
- HeelMaster_Cons = cmds.parentConstraint( Roll_Heel_IK_Control , ( Roll_Toe_IK_Control + '_Grp' ) , mo = True )
- Immediate_Children = cmds.listRelatives( Roll_Toe , children = True )
- if len( Immediate_Children ) > 2:
- tmp = Immediate_Children[2:]
- cmds.select( clear = True )
- for x in tmp:
- cmds.select( ( x + '_PinMaster' ) , add = True )
- cmds.pickWalk( d = 'down' )
- cmds.pickWalk( d = 'left' )
- cmds.delete()
- cmds.parentConstraint( ( Roll_Toe + '_Jnt' ) , ( x + '_PinMaster' ) , mo = True )
- if Type < 3: # hand version?
- if ToeHeel is True:
- 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
- ToeHeel_Handle = Handle_Main[0]
- cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
- Toe_to_HeelCons = cmds.parentConstraint( Roll_Toe_IK_Control , Heel_Handle , mo = True )
- Toe_to_HeelCons = cmds.parentConstraint( Roll_Toe_IK_Control , ToeHeel_Handle , mo = True )
- HeelMaster_Cons = cmds.parentConstraint( Roll_Heel_IK_Control , ( Roll_Toe_IK_Control + '_Grp' ) , mo = True )
- Immediate_Children = cmds.listRelatives( Roll_Toe , children = True )
- if len( Immediate_Children ) > 2:
- tmp = Immediate_Children[2:]
- cmds.select( clear = True )
- for x in tmp:
- cmds.select( ( x + '_PinMaster' ) , add = True )
- cmds.pickWalk( d = 'down' )
- cmds.pickWalk( d = 'left' )
- cmds.delete()
- cmds.parentConstraint( ( Roll_Toe + '_Jnt' ) , ( x + '_PinMaster' ) , mo = True )
- def RigBox_Guide_To_Rig_IK( Items , Mode ): ## IK SYSTEM
- print 'ikwip'
- All_IK_Found = []
- All_IK_Starts_Found = []
- All_IK_Ends_Found = []
- pass # finding the start of all IK guide types.
- for x in Items:
- SystemType = RigBox_ReadSystemTypeAtr( x )
- if SystemType == Mode :
- All_IK_Found.append( x )
- All_IK_Found_As_Joints = []
- for x in Items:
- All_IK_Found_As_Joints.append( ( x + Suffix_Joints[3] ) )
- print 'All ik Joints found'
- print All_IK_Found_As_Joints
- print '\n'
- pass # find all the IK ENDS!
- for x in All_IK_Found_As_Joints:
- cmds.select( clear = True )
- cmds.select( x )
- current = cmds.ls( selection = True )
- Immediate_Children = cmds.listRelatives( current , children = True )
- if Immediate_Children is None:
- All_IK_Ends_Found.append( current[0].replace( Suffix_Joints[3] , '' ) ) # its the end of a chain, but also ik
- else:
- Still_IK = False
- for child in Immediate_Children:
- SystemType_Test = RigBox_ReadSystemTypeAtr( child )
- if SystemType_Test == Mode:
- Still_IK = True # ik found, go deeper..
- if Still_IK is False:
- All_IK_Ends_Found.append( current[0].replace( Suffix_Joints[3] , '' ) )
- pass # find all the IK STARTS!
- for x in All_IK_Found_As_Joints:
- cmds.select( clear = True )
- cmds.select( x )
- current = x
- Immediate_Parents = cmds.listRelatives( current , parent = True )
- if len( Immediate_Parents ) > 0:
- IsIn_IK_List_Test = In_List_Test( Immediate_Parents[0] , All_IK_Found_As_Joints )
- if IsIn_IK_List_Test is None:
- print ( 'Start of IK ' + current.replace( Suffix_Joints[3] , '' ) )
- All_IK_Starts_Found.append( current.replace( Suffix_Joints[3] , '' ) ) # its the start of a chain, but also ik
- All_IK_Mids_Found = All_IK_Found
- print ( 'All IK Starts found: ' )
- print All_IK_Starts_Found
- print ( 'All IK Ends found: ' )
- print All_IK_Ends_Found
- print '\n'
- pass # To find all the middle IK Controls that will need to be rigged up.
- for x in All_IK_Mids_Found:
- IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Ends_Found )
- if IsIn_IK_List_Test_Start is True:
- All_IK_Mids_Found.remove( x )
- print ( 'removing from IK Mids: ' + x )
- for x in All_IK_Mids_Found:
- IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Starts_Found )
- if IsIn_IK_List_Test_Start is True:
- All_IK_Mids_Found.remove( x )
- print ( 'removing from IK Mids: ' + x )
- pass # To find all the middle IK Controls that will need to be rigged up.
- for x in All_IK_Mids_Found:
- IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Ends_Found )
- if IsIn_IK_List_Test_Start is True:
- All_IK_Mids_Found.remove( x )
- print ( 'removing from IK Mids: ' + x )
- for x in All_IK_Mids_Found:
- IsIn_IK_List_Test_Start = In_List_Test( x , All_IK_Starts_Found )
- if IsIn_IK_List_Test_Start is True:
- All_IK_Mids_Found.remove( x )
- print ( 'removing from IK Mids: ' + x )
- print ('ik mids now = :' )
- for x in All_IK_Mids_Found:
- print x
- print '\n'
- def RigBox_IK_Mid_Cons( Item , Mode ):
- IK_Break_Test = cmds.getAttr( ( Item.replace( Suffix_Joints[3] , '' ) ) + '.' + Extra_Options[0] ) #IF_IK_allow_Breakable_IK_Setup
- Grps = []
- Jnts = []
- Test_Local = RigBox_ReadExtraTypeAtr( Item )
- if Test_Local == 'Local':
- Grps.append( Item + '_Control_IK_Grp' )
- Grps.append( Item + '_Control_Local_IK_Grp' )
- Jnts.append( Item + Suffix_Joints[3] )
- Jnts.append( Item + Suffix_Joints[3] )
- else:
- Grps.append( Item + '_Control_IK_Grp' )
- Jnts.append( Item + Suffix_Joints[3] )
- count = 0
- while count < len(Grps):
- if IK_Break_Test is 0: # allowed go ahead
- Grp = Grps[ count ]
- Joint = Jnts[ count ]
- cmds.parentConstraint( Joint , Grp , mo = True )
- if IK_Break_Test is 1: # NOT allowed, hide control instead.
- Grp = Grps[ count ]
- Joint = Jnts[ count ]
- cmds.parentConstraint( Joint , Grp , mo = True )
- cmds.setAttr( ( Grp + '.v' ) , 0 )
- count+=1
- IK_Go = False
- if len( All_IK_Starts_Found ) is len( All_IK_Ends_Found ):
- if All_IK_Starts_Found[0] == All_IK_Ends_Found[0]:
- print 'Possible issue with IK handles, number of IK starts and IK ends dont match?'
- else:
- print 'Starting IK Handles, all seems well'
- IK_Go = True
- else:
- print 'Possible issue with IK handles, number of IK starts and IK ends dont match?'
- IK_Handles = []
- Solver = 'ikRPsolver'
- pass # Solver = 'ikSCsolver'
- if IK_Go is True:
- for x in All_IK_Mids_Found:
- RigBox_IK_Mid_Cons( x , Mode )
- if IK_Go is True:
- pass # creating all the IK Handle..
- count = 0
- while count < len( All_IK_Starts_Found ):
- Start = All_IK_Starts_Found[ count ]
- FindParent_Start = cmds.listRelatives( ( Start + Suffix_Joints[1] ) , parent = True )
- if FindParent_Start[0] == Joint_Grps[2]:
- pass
- else:
- cmds.parent( ( Start + Suffix_Joints[1] ) , Joint_Grps[2] ) # operation on the normal ik
- cmds.parent( ( Start + Suffix_Joints[3] ) , Joint_Grps[3] ) # operation on the ik extra..
- pass # items re-parented if need be!
- cmds.joint ( ( Start + Suffix_Joints[1] ) , edit = True , setPreferredAngles = True , children= True)
- cmds.joint ( ( Start + Suffix_Joints[3] ) , edit = True , setPreferredAngles = True , children= True)
- End = All_IK_Ends_Found[ count ]
- print Start
- print End
- 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
- cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
- pass # Constrain the start of the Handle
- Test_Local = RigBox_ReadExtraTypeAtr( Start )
- if Test_Local == 'Local':
- Additional = '_Local_IK'
- else:
- Additional = '_IK'
- cmds.pointConstraint( ( Start + '_Control' + Additional ) , ( Start + Suffix_Joints[3] ) , mo = True )
- cmds.orientConstraint( ( Start + Suffix_Joints[3] ) , ( Start + '_Control' + Additional ) , mo = False )
- ##Start control is edited here that controls the start of ik chain but no rotation should be allowed.
- cmds.setAttr( ( Start + '_Control' + Additional +'.rotateX' ) , keyable = False )
- cmds.setAttr( ( Start + '_Control' + Additional +'.rotateY' ) , keyable = False )
- cmds.setAttr( ( Start + '_Control' + Additional +'.rotateZ' ) , keyable = False )
- cmds.setAttr( ( Start + '_Control' + Additional + '.v' ) , lock = True , keyable = False ,
- channelBox = False )
- cmds.setAttr( ( End + '_Control' + Additional + '.v' ) , lock = True , keyable = False ,
- channelBox = False )
- pass # now constrain the start controls group to the correct pin!
- cmds.parentConstraint( ( Start + '_PinFollow' ) , ( Start + '_Control_IK_Grp' ) , mo = True )
- pass # Constrain the end of the Handle
- Test_Local = RigBox_ReadExtraTypeAtr( End )
- if Test_Local == 'Local':
- Additional = '_Local_IK'
- else:
- Additional = '_IK'
- cmds.parentConstraint( ( End + '_Control' + Additional ) , Handle_Main[0] , mo = True )
- 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.
- IK_Handles.append( Handle_Main[0] ) #add to the handles list.
- print 'twatish'
- pass # PoleVector stage!
- pass # Find if one has already been added to the guides?
- pass # grab a list of all the joints affected by the current handle
- Joint_List_Affected = cmds.ikHandle( Handle_Main[0] , query = True , jl= True )
- cmds.select( Joint_List_Affected[-1] )
- cmds.pickWalk( d = 'down' )
- Extra_Joint = cmds.ls( selection = True , type = 'joint')
- Joint_List_Affected.append( Extra_Joint[0] )
- Pole = []
- Guides = []
- for Joint in Joint_List_Affected:
- tmp44 = Joint.replace( Suffix_Joints[3] , '' )
- Guides.append( tmp44 )
- PoleTest = RigBox_IK_PoleFind( Guides )
- if PoleTest == 'Not Found':
- print 'poley not foundy'
- pass # no object found, will make a default version instead
- print 'jnts used for pole v:'
- print Joint_List_Affected
- World_Position = RigBox_IK_PolePosition( Joint_List_Affected )
- cmds.select( clear = True )
- cmds.select( Guides[0] )
- tmp = RigBox_Guide_PoleV('Auto') # create the guide version
- cmds.xform( tmp , t = World_Position , ws = True )
- PoleTest = tmp[0]
- RigBox_ControlCreate( PoleTest ) # create the real controller version
- pass # constrain the pole vector / ik handle.
- MakeSureNameIsString = isinstance( PoleTest , str)
- if MakeSureNameIsString is True:
- pass
- else:
- PoleTest = ''.join(PoleTest)
- cmds.poleVectorConstraint( ( PoleTest + '_Control_IK' ) , Handle_Main[0] )
- pass # setup the visibility of the control.
- cmds.connectAttr( ( Joint_List_Affected[0].replace( Suffix_Joints[3] , Suffix_Joints[0] ) + '.' + IK_FK_Blend_Atr[0] ) , ( PoleTest + '_Control_IK' + '.v' ) )
- pass # now to add the final control if ikfk.
- if Mode == 'IKFK':
- End_Guide = Guides[-1]
- End_Joint = ( End_Guide + Suffix_Joints[0] )
- cmds.select( clear = True )
- cmds.select(End_Joint)
- cmds.pickWalk( d = 'up' )
- Second_TO_End_Joint = cmds.ls( selection = True , type = 'joint' )
- End_Control_Name = ( End_Guide + '_IKFK' )
- cmds.select( clear = True )
- pass # create the control object.
- Fake_Control = RigBox_Guide_Piece( End_Control_Name , 'IKFK' )
- Real_Control = RigBox_ControlCreate( Fake_Control[0] ) # create the real controller version
- cmds.delete( Fake_Control )
- for x in Guides: # connect up the joints own ikfk attribute to the main switch!
- IKFK_Joint = ( x + Suffix_Joints[0] )
- cmds.connectAttr( ( Real_Control + '.FK_IK_Switch' ) , ( IKFK_Joint + '.' + IK_FK_Blend_Atr[0] ) )
- pass # now to pin the switch to the end joint in the right place.
- cmds.parentConstraint( End_Joint , ( End_Control_Name + '_Control_Grp' ) , mo = False )
- pass # now to find the axis to move in.
- Axis = FindAxis_Direction( ( End_Joint , Second_TO_End_Joint ) , 'Away' )
- To_Move = ChainLength( ( Second_TO_End_Joint , End_Joint ) )
- cmds.setAttr( ( End_Control_Name + '_Control.' + Axis ) , ( To_Move * .6 ) ) # go crazy all out on a scale.
- #now connect the twist override to the right IK handle:
- cmds.connectAttr( ( Real_Control + '.FK_IK_TwistOveride' ) , ( Handle_Main[0] + ".twist" ) )
- count+=1
- No_IKBreak_Setup( IK_Handles )
- if len( All_IK_Ends_Found ) > 0:
- print 'ALL IK ENDS FOUND :'
- print All_IK_Ends_Found
- count = 0
- for x in All_IK_Ends_Found:
- ListOfChildLists = []
- ChildrenFound = cmds.listRelatives( x , c = True , ad = True , type = 'transform' ) # should feed back a list
- ChildrenFound.append( x ) # adding the end joint!
- ChildrenFound.append( All_IK_Starts_Found[ count ] ) # adding the end joint!
- ListOfChildLists.append( ChildrenFound )
- RigBox_Guide_To_Rig_RollControl( ListOfChildLists )
- count+=1
- else:
- pass
- def No_IKBreak_Setup( Handles ): # does the vanilla setup of no stretch ik.
- pass # fancy version is still wip, normal versions works perfectly.
- for Handle in Handles:
- Joint_List_Affected = cmds.ikHandle( Handle , query = True , jl= True )
- cmds.select( Joint_List_Affected[-1] )
- cmds.pickWalk( d = 'down' )
- Extra_Joint = cmds.ls( selection = True , type = 'joint')
- Joint_List_Affected.append( Extra_Joint[0] )
- pass # is IK Breakable On?
- IK_Break_Test = cmds.getAttr( ( Joint_List_Affected[0].replace( Suffix_Joints[3] , '' ) ) + '.' + Extra_Options[0] ) #IF_IK_allow_Breakable_IK_Setup
- print Joint_List_Affected[0].replace( Suffix_Joints[3] , '' )
- if IK_Break_Test is 0:
- pass # IK Break is on
- print 'ik breakable is wip'
- print Joint_List_Affected
- Solver = 'ikRPsolver'
- pass # Creating IK Handles for each 2 joints found in the above then Con straining all them to the correct controls
- count = 0
- while count < len( Joint_List_Affected ):
- if ( count + 1 ) < ( len( Joint_List_Affected ) ):
- Start = ( Joint_List_Affected[ count ].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
- End = ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
- Name = ( Joint_List_Affected[ count ] )
- Handle_Chain = cmds.ikHandle( sj = Start , ee = End , n = ( Name + '_Chain_Handle_IK' ) , sol = Solver , srp = True , s = "sticky" ) #ik handle
- cmds.parent( Handle_Main[0] , RigBox_All_Grps[3] )
- Test_Local = RigBox_ReadExtraTypeAtr( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[1] , '' ) ) )
- if Test_Local == 'Local':
- Additional = '_Local_IK'
- else:
- Additional = '_IK'
- Control_Start = ( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
- cmds.orientConstraint( ( Joint_List_Affected[ ( count ) ].replace( Suffix_Joints[3] , '' )) , Control_Start , mo = False )
- Test_Local = RigBox_ReadExtraTypeAtr( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[1] , '' ) ) )
- if Test_Local == 'Local':
- Additional = '_Local_IK'
- else:
- Additional = '_IK'
- Control_End = ( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
- pass # constrain the handles in place correctly.
- ToBeConstrained_To = ( ( Joint_List_Affected[ ( count + 1 ) ].replace( Suffix_Joints[3] , '' ) ) + '_Control' + Additional )
- cmds.pointConstraint( ToBeConstrained_To , Handle_Chain[0] , mo = True )
- pass # now create the distance nodes for each handle to compare length against.
- Length = ChainLength( ( Start , End ) )
- Distance_NodeOutPut = DistanceNode_Setup( Control_Start , Control_End , Name )
- # MultiDivide_NodeOutPut = MultiDivNode_Setup( Distance_Node , Length , Name , 2 )
- ChannelToConnect = FindAxis_Direction( ( Start , End ) , 'Along' )
- cmds.connectAttr( Distance_NodeOutPut , ( End + '.' + ChannelToConnect ) )
- # need to use condition nodes,
- # first only allow if the break is on
- # check against the chain length.
- count+=1
- pass # cons the start joint to the correct control.
- JointStartToCons = ( Joint_List_Affected[0].replace( Suffix_Joints[3] , Suffix_Joints[1] ) )
- Guide = Joint_List_Affected[0].replace( Suffix_Joints[3] , '' )
- Test_Local = RigBox_ReadExtraTypeAtr( Guide )
- if Test_Local == 'Local':
- Additional = '_Local_IK'
- else:
- Additional = '_IK'
- ControlToConsTo = ( Guide + '_Control' + Additional )
- cmds.pointConstraint( ControlToConsTo , JointStartToCons , mo = True )
- cmds.orientConstraint( ControlToConsTo , JointStartToCons , mo = True )
- print 'cunt'
- #need to constrain the control orientation to the ik joint as its not animateable and will look funky.
- # count = 0
- # while count < len( Joint_List_Affected ):
- # count+=1
- if IK_Break_Test is 1: # IK Break is off, boring.
- pass # IK Break is off
- for joint in Joint_List_Affected:
- print 'basic ik blending'
- RigBox_Blend_2_Items( ( joint.replace( Suffix_Joints[3] , Suffix_Joints[1] ) ) , ( joint.replace( Suffix_Joints[1] , Suffix_Joints[3] ) ) , 'UseBlends' , False )
- def DistanceNode_Setup( Start , End , Name ): # creates a distance node named item_dn
- Tmp_Node = cmds.shadingNode( 'distanceBetween' , asUtility = True , name = ( Name + '_Dist_node') )
- cmds.connectAttr( ( Start + '.worldMatrix' ) , ( Tmp_Node + '.inMatrix1' ) )
- cmds.connectAttr( ( End + '.worldMatrix' ) , ( Tmp_Node + '.inMatrix2' ) )
- return ( Tmp_Node + '.distance' )
- def MultiDivNode_Setup( Input1_Item , Input2_Float , Name , Operation ): # creates a multiply and divide node named item_dn
- pass # Operation , 1 is multiply, 2 is divide , 3 is power.
- Tmp_Node = cmds.shadingNode( 'multiplyDivide' , asUtility = True , name = ( Name + '_MultiDist_node') )
- cmds.connectAttr( Input1_Item , ( Tmp_Node + '.input1X' ) )
- cmds.setAttr( ( Tmp_Node + '.input2X' ) , Input2_Float ) # set the float value
- cmds.setAttr( ( Tmp_Node + '.operation' ) , Operation ) #FULL Stretch..
- return ( Tmp_Node + '.outputX' )
- def ConditionNode_Setup( Input1_Item , Input2_Item , Name , Operation ): # creates a multiply and divide node named item_dn
- pass # Operation , 1 is multiply, 2 is divide , 3 is power.
- Tmp_Node = cmds.shadingNode( 'condition' , asUtility = True , name = ( Name + '_Condition_node') )
- cmds.setAttr( ( Tmp_Node + '.firstTerm' ) , Input1_Item )
- cmds.setAttr( ( Tmp_Node + '.secondTerm' ) , Input2_Item )
- cmds.setAttr( ( Tmp_Node + '.operation' ) , Operation )
- # return output if True
- # return output if False
- def FindAxis_Direction( Input , Type ):
- Channels = [ 'sx' , 'sy' , 'sz' ]
- Channels_Ts = [ 'tx' , 'ty' , 'tz' ]
- Chan_Results = []
- Items = []
- for x in Input:
- MakeSureNameIsString = isinstance( x , str)
- if MakeSureNameIsString is True:
- pass
- else:
- x = ''.join(x)
- Items.append( x )
- pass # move a point to between the 2 points in space.
- tmp = cmds.spaceLocator()
- tmp_cons = cmds.parentConstraint( Items[0] , tmp , mo = False )
- cmds.parentConstraint( Items[1] , tmp , mo = False )
- cmds.delete( tmp_cons )
- Scale_Pivot = cmds.group( em = True ) #doesnt exhist, make it.
- tmp_scale_cons = cmds.parentConstraint( Items[0] , Scale_Pivot , mo = False )
- cmds.delete( tmp_scale_cons )
- cmds.parent( tmp , Scale_Pivot )
- Control_Distance = ChainLength( ( Items[0] , tmp ) )
- for chan in Channels:
- cmds.scale( 1 , 1 , 1 , Scale_Pivot )
- cmds.setAttr( ( Scale_Pivot + '.' + chan ) , 2 )
- Chan_Results.append( ( ChainLength( ( Items[0] , tmp ) ) ) )
- Channel_To_Use = ''
- pass # print Input
- pass # print Chan_Results
- if Type == 'Away':
- tmp33 = min(enumerate( chan ) , key = lambda x: x[1])[0]
- Channel_To_Use = Channels_Ts[ tmp33 ]
- if Type == 'Along':
- tmp33 = min(enumerate( chan ), key = lambda x: abs(x[1]- Control_Distance ))
- Channel_To_Use = Channels_Ts[ tmp33[0] ]
- pass # now we know which channel laid along or away from the axis.! yay
- cmds.delete( tmp ) # reset the damage.
- cmds.delete( Scale_Pivot ) # reset the damage.
- return Channel_To_Use
- def ChainLength( Items ): # returns the distance from start to end in world space of the supplied items.
- Distances = []
- import math
- count = 0
- while ( count + 1 ) < len( Items ):
- Pos1 = cmds.xform( Items[ count ] , query = True , t = True , ws = True)
- Pos2 = cmds.xform( Items[ ( count + 1 ) ] , query = True , t = True , ws = True)
- Xd = ( Pos1[0] - Pos2[0] )
- Xd = ( Xd * Xd )
- Yd = ( Pos1[1] - Pos2[1] )
- Yd = ( Yd * Yd )
- Zd = ( Pos1[2] - Pos2[2] )
- Zd = ( Zd * Zd )
- Distance = math.sqrt( Xd + Yd + Zd )
- Distances.append( Distance )
- count+=1
- return sum( Distances )
- 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..
- Items = cmds.ls( selection = True )
- Pole = Items[-1]
- NewItems = Items[0: (len( Items ) - 1)]
- print ( NewItems )
- NewPosition = RigBox_IK_PolePosition( Items )
- cmds.xform( Pole , t = NewPosition , ws = True ) # move the pivot perfectly to correct world space!
- def RigBox_IK_PolePosition( Items ):
- Pole_Position =[ 0.0 , 0.0 , 0.0 ]
- if len( Items ) is 2:
- pass # using 2 items.
- tmp = cmds.spaceLocator()
- tmp_cons = cmds.parentConstraint( Items[0] , tmp , mo = False )
- cmds.parentConstraint( Items[1] , tmp , mo = False )
- cmds.delete( tmp_cons )
- Channel_To_Use = FindAxis_Direction( Items , 'Away' )
- Control_Distance = ChainLength( ( Items[0] , tmp ) )
- cmds.setAttr( ( tmp[0] + '.' + Channel_To_Use ) , Control_Distance ) # go crazy all out on a scale.
- pass # cmds.setAttr( ( Scale_Pivot + '.' + Chan_Results[0] ) , 2.5 ) # go crazy all out on a scale.
- Pole_Position = cmds.xform( tmp , query = True , t = True , ws = True)
- cmds.delete( tmp )
- if len( Items ) > 2:
- pass # using 3 items.
- tmp = cmds.spaceLocator()
- tmp_pin = cmds.spaceLocator()
- tmp_knee = cmds.spaceLocator()
- cmds.parent( tmp_pin , tmp )
- cmds.parent( tmp_knee , tmp )
- tmp_point_cons = cmds.pointConstraint( Items[0] , Items[-1] , tmp_knee )
- cmds.pointConstraint( Items[0] , tmp )
- cmds.pointConstraint( Items[-1] , tmp_pin )
- cmds.aimConstraint( Items[-1] , tmp , wuo = Items[ ( len( Items ) / 2 ) ] , wut='object' )
- cmds.delete( tmp_point_cons )
- To_Move = ChainLength( ( tmp_knee , tmp ) )
- cmds.setAttr( ( tmp_knee[0] + '.' + 'ty' ) , ( To_Move * ( Global_Scene_Size * .2 ) ) ) # go crazy all out on a scale.
- Pole_Position = cmds.xform( tmp_knee , query = True , t = True , ws = True)
- cmds.delete( tmp )
- return Pole_Position
- def RigBox_IK_PoleFind( Items ): # fed a list of items checks all children for the pole control.
- PoleFound = 'Not Found'
- for x in Items:
- Children = cmds.listRelatives( x , children = True )
- pass # print Children
- if Children is None:
- pass
- else:
- for Child in Children:
- IsRigBox_Item = cmds.attributeQuery( 'RigBox_Guide_SystemType' , node = Child , ex=True )
- if IsRigBox_Item is True: # is part of rigbox
- IsIt_A_Pole = (RigBox_ReadSystemTypeAtr( Child )) == 'PoleV' # check if current item has polev as an option?
- if IsIt_A_Pole is True:
- PoleFound = Child
- print ( 'Found polevector:: ' + Child + ' in list of Items' )
- print Items
- break
- return PoleFound
- def RigBox_Guide_To_Rig_IKFK( Items ):
- print 'ikfkwip'
- # RigBox_Guide_To_Rig_IK( Items )
- # pass # Start creating the copies of the guides for use as FK controllers..
- # for x in Items:
- # cmds.select( clear = True )
- # Original_Guide = x.replace( '_Jnt' , '' )
- # RigBox_ControlCreate( Original_Guide )
- 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!
- for x in Items:
- print x
- Operation = []
- count = 0
- cmds.select( clear = True )
- cmds.select( x )
- while count < 2:
- cmds.pickWalk( direction='up' )
- Current_Parent = cmds.ls( selection = True , transforms = True )
- All_GuidesFound = RigBox_FindAll( 'Guide' )
- TestItsAGuide = In_List_Test( Current_Parent[0] , All_GuidesFound )
- print x
- print TestItsAGuide
- print 'boob'
- if TestItsAGuide is True:
- Operation =[ x , Current_Parent[0] ]
- break
- count+=1
- if len( Operation ) is 2:
- print 'booombtastic'
- ItemToUse = [ None ]
- counter = 0
- while counter < 1:
- TestControl = cmds.ls( ( Current_Parent[0] + '_Control' ) )
- if len( TestControl ) > 0:
- ItemToUse = TestControl
- break
- TestControlFK = cmds.ls( ( Current_Parent[0] + '_Control_FK' ) )
- if len( TestControlFK ) > 0:
- ItemToUse = TestControlFK
- break
- TestJnt = cmds.ls( ( Current_Parent[0] + Suffix_Joints[0] ) )
- if len( TestJnt ) > 0:
- ItemToUse = TestJnt
- break
- counter+=1
- print ItemToUse
- if len( ItemToUse ) is None :
- pass
- else:
- cmds.parentConstraint( ItemToUse[0] , ( x + '_Control_Grp' ) , mo = True )
- def RigBox_Guide_To_Rig_FK( Items , Mode ):
- print 'fk wip'
- pass # constraining all fk joints found to there corresponding fk controls, making a check for the local variety too..
- for x in Items:
- Guide_Extra_Type = RigBox_ReadExtraTypeAtr( x )
- if Guide_Extra_Type == 'Local':
- RigBox_Blend_2_Items( ( x + Suffix_Joints[2] ) , ( x + '_Control_Local_FK' ) , 'UseCons' , True )
- else:
- RigBox_Blend_2_Items( ( x + Suffix_Joints[2] ) , ( x + '_Control_FK' ) , 'UseCons' , True )
- pass # Now to create the 4 way follow / dont follow Constraints setup
- for x in Items:
- Control_Grp = ( x + '_Control_FK_Grp' )
- Control = ( x + '_Control_FK' )
- cmds.pointConstraint( ( x + '_PinFollow' ) , Control_Grp , mo = False )
- cmds.pointConstraint( ( x + '_PinNoFollow' ) , Control_Grp , mo = False )
- cmds.orientConstraint( ( x + '_PinFollow' ) , Control_Grp , mo = False )
- cmds.orientConstraint( ( x + '_PinNoFollow' ) , Control_Grp , mo = False )
- pass # Names to use for the fields../ channels
- cmds.addAttr( Control , shortName= Follow_Channel_Names[0] , attributeType='float' , min = 0.0 , max=1.0 )
- cmds.addAttr( Control , shortName= ( 'Rev_' + Follow_Channel_Names[0] ) , attributeType='float' , min = 0.0 , max=10.0 )
- cmds.addAttr( Control , shortName= Follow_Channel_Names[1] , attributeType='float' , min = 0.0 , max=1.0 )
- cmds.addAttr( Control , shortName= ( 'Rev_' + Follow_Channel_Names[1] ) , attributeType='float' , min = 0.0 , max=10.0 )
- for chans in Follow_Channel_Names:
- cmds.setAttr( ( Control + '.' + chans ) , 1 )
- cmds.setAttr( ( Control + '.' + chans ) , lock = False , channelBox = True )
- cmds.setAttr( ( Control + '.' + chans ) , keyable = True )
- Reverse_Node = cmds.shadingNode( 'reverse' , asUtility = True , n = ( Control + '_Rev_Node' ) )
- cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[0] ) , ( Reverse_Node + '.inputX' ) )
- cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[1] ) , ( Reverse_Node + '.inputY' ) )
- cmds.connectAttr( ( Reverse_Node + '.outputX' ) , ( Control + '.Rev_' + Follow_Channel_Names[0] ) )
- cmds.connectAttr( ( Reverse_Node + '.outputY' ) , ( Control + '.Rev_' + Follow_Channel_Names[1] ) )
- Cons_Name = cmds.pointConstraint( Control_Grp , query=True )
- Cons_Targets = cmds.pointConstraint( Control_Grp , query=True , tl=True )
- cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[0] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )
- cmds.connectAttr( ( Control + '.Rev_' + Follow_Channel_Names[0] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' ) )
- Cons_Name = cmds.orientConstraint( Control_Grp , query=True )
- Cons_Targets = cmds.orientConstraint( Control_Grp , query=True , tl=True )
- cmds.connectAttr( ( Control + '.' + Follow_Channel_Names[1] ) , ( Cons_Name + '.' + Cons_Targets[0] + 'W0' ) )
- cmds.connectAttr( ( Control + '.Rev_' + Follow_Channel_Names[1] ) , ( Cons_Name + '.' + Cons_Targets[1] + 'W1' ) )
- pass # 4 way follow / dont follow Constraints setup DONE!
- pass # creating the controller duplication class below..
- def Controller_Duplication( Name_To_Dupe , NewName ):
- global All_Controls_Made
- Controller_Duped = cmds.duplicate( Name_To_Dupe , name = NewName , rc = True , ic = False )
- RigBox_RemoveAllAtr( Controller_Duped[0] )
- # cmds.parent( Controller_Duped , 'Character_Rig_Controls' )
- cmds.select( Controller_Duped )
- cmds.select( Controller_Duped[0] , d = True)
- cmds.delete()
- cmds.parent( Controller_Duped[0] , 'Character_Rig_Controls' )
- All_Controls_Made.append( Controller_Duped[0] )
- return Controller_Duped[0]
- def Controller_Vis( Item , Item_1 , Item_2 ):
- cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Item_2 + '.v' ) )
- cmds.connectAttr( ( Item + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( Item_1 + '.v' ) )
- def RigBox_ControlCreate( Guide ):
- global Global_Local_Control_Size
- Size_To_Scale = [ Global_Local_Control_Size , Global_Local_Control_Size , Global_Local_Control_Size ]
- print ( 'creating the control objects before setting up..: ' + Guide )
- pass #first grab the details we need
- Guide_System_Type = RigBox_ReadSystemTypeAtr( Guide )
- Guide_Extra_Type = RigBox_ReadExtraTypeAtr( Guide )
- pass # Start creating the controller with correct options / setup.... takes into consideration the 'extras options'..
- cmds.select( clear = True )
- if Guide_System_Type == 'IKFK':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )
- cmds.select( clear = True )
- Tmp_Pivot = cmds.group( em = True , world = True ) #doesnt exhist, make it.
- tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )
- pass # grab world transforms
- Guide_Trans = cmds.xform( Tmp_Pivot , query=True , t=True , ws = True)
- pass # grab world rotations
- Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
- pass # set the pivot of the fk pivot!
- cmds.parent( New_Control_Item , Tmp_Pivot )
- cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
- cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space!
- cmds.parent( New_Control_Item , 'Character_Rig_Controls' )
- cmds.delete( Tmp_Pivot )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )
- if Guide_Extra_Type == 'Local':
- pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
- cmds.select( clear = True )
- Tmp_Pivot = cmds.group( em = True ) #doesnt exhist, make it.
- tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )
- pass # grab world transforms
- Guide_Trans = cmds.xform( Tmp_Pivot , query=True , t=True , ws = True)
- pass # grab world rotations
- Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
- pass # set the pivot of the fk pivot!
- cmds.parent( New_Control_Item , Tmp_Pivot )
- cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
- cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space!
- cmds.parent( New_Control_Item , 'Character_Rig_Controls' )
- cmds.delete( Tmp_Pivot )
- cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )
- RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_FK_Grp' ) , ( Guide + '_Control' + '_FK' ) , 'UseCons' , True )
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_IK' ) )
- cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )
- RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_IK_Grp' ) , ( Guide + '_Control' + '_IK' ) , 'UseCons' , True )
- if Guide_System_Type == 'IK':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )
- if Guide_Extra_Type == 'Local':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_IK' ) )
- cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
- RigBox_GrouperCtrls( New_Control_Item )
- RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_IK_Grp' ) , ( Guide + '_Control' + '_IK' ) , 'UseCons' , True )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( New_Control_Item + '.v' ) )
- if Guide_System_Type == 'FK':
- cmds.select( clear = True )
- Tmp_Pivot = cmds.group( em = True ) #doesnt exhist, make it.
- tmp_scale_cons = cmds.parentConstraint( ( Guide + '_Local_Jnt' ) , Tmp_Pivot , mo = False )
- pass # grab world transforms
- Guide_Trans = cmds.xform( Tmp_Pivot , query=True , t=True , ws = True)
- pass # grab world rotations
- Guide_Rots = cmds.xform( Tmp_Pivot , query=True , ro=True , ws = True )
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
- pass # set the pivot of the fk pivot!
- cmds.parent( New_Control_Item , Tmp_Pivot )
- cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
- cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space !
- cmds.parent( New_Control_Item , 'Character_Rig_Controls' )
- cmds.delete( Tmp_Pivot )
- pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_FK' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )
- if Guide_Extra_Type == 'Local':
- pass # grab world transforms
- Guide_Trans = cmds.xform( ( Guide + '_Local_Jnt' ) , query=True , t=True , ws = True)
- pass # grab world rotations
- Guide_Rots = cmds.xform( ( Guide + '_Local_Jnt' ) , query=True , ro=True , ws = True )
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
- pass # set the pivot of the fk pivot!
- cmds.xform( New_Control_Item , pivots = Guide_Trans , ws = True ) # move the pivot perfectly to correct world space !
- cmds.parent( New_Control_Item , ( Guide + '_Local_Jnt' ) )
- cmds.makeIdentity( New_Control_Item , apply = True, t = 1 , r = 1, s = 0 , n = 2 ) #all 0
- cmds.parent( New_Control_Item , 'Character_Rig_Controls' )
- pass # New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control_Local' + '_FK' ) )
- cmds.scale( Size_To_Scale[0] , Size_To_Scale[1] , Size_To_Scale[2] , New_Control_Item )
- RigBox_GrouperCtrls( New_Control_Item )
- RigBox_Blend_2_Items( ( Guide + '_Control_Local' + '_FK_Grp' ) , ( Guide + '_Control' + '_FK' ) , 'UseCons' , True )
- cmds.connectAttr( ( Guide + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( New_Control_Item + '.v' ) )
- if Guide_System_Type == '_':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- if Guide_System_Type == 'PoleV': # got to treat this like an ik object..
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' + '_IK' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- if Guide_System_Type == 'Aim_Target':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- if Guide_System_Type == 'Aim_Affected':
- New_Control_Item = Controller_Duplication( Guide , ( Guide + '_Control' ) )
- RigBox_GrouperCtrls( New_Control_Item )
- global All_Controls_Made
- All_Controls_Made.append( New_Control_Item )
- print New_Control_Item
- return New_Control_Item
- def RigBox_PinCreator():
- print '\n---[[[[[[[[[ Starting Pinning System ]]]]]]]]]---'
- pass # create the groups..
- PinsFollow_Group = cmds.group( em = True , name = 'Character_Rig_Pins_Follow' , parent = 'Character_Rig_Pins' ) #doesnt exhist, make it.
- PinsNoFollow_Group = cmds.group( em = True , name = 'Character_Rig_Pins_NoFollow' , parent = 'Character_Rig_Pins' ) #doesnt exhist, make it.
- All_Guides = RigBox_FindAll( 'Guide' )
- for x in All_Guides:
- if '_Local' in x:
- pass
- else:
- Pin_Master = cmds.group( em = True , name = ( x + '_PinMaster' ) , parent = 'Character_Rig_Pins_Follow' )
- Pin_Follow = cmds.group( em = True , name = ( x + '_PinFollow' ) , parent = Pin_Master )
- Pin_NoFollow = cmds.group( em = True , name = ( x + '_PinNoFollow' ) , parent = 'Character_Rig_Pins_NoFollow' )
- Test = cmds.ls( ( x + '_Local_Jnt' ) )
- if len( Test ) > 0:
- tmp1 = cmds.parentConstraint( ( x + '_Local_Jnt' ), Pin_Master , mo = False )
- else:
- tmp1 = cmds.parentConstraint( x , Pin_Master , mo = False )
- cmds.delete( tmp1 )
- cmds.parentConstraint( Pin_Master , Pin_Follow , mo = False )
- tmp1 = cmds.parentConstraint( Pin_Follow , Pin_NoFollow , mo = False )
- cmds.delete( tmp1 )
- RelativeToUse = ['']
- count = 0
- while count < 1:
- TestGuide = cmds.ls( x )
- if len( TestGuide ) > 0:
- RelativeToUse[0] = TestGuide
- break
- TestJnt = cmds.ls( ( x + Suffix_Joints[0] ) )
- if len( TestJnt ) > 0:
- RelativeToUse[0] = TestJnt
- break
- count+=1
- FindParent_Guide = cmds.listRelatives( RelativeToUse[0] , parent = True )
- Test_Its_Guide = cmds.attributeQuery( 'RigBox_Guide_ControlType' , node = FindParent_Guide[0] , ex=True )
- if Test_Its_Guide is False:
- pass
- else:
- Parent_Guide_System_Type = RigBox_ReadSystemTypeAtr( FindParent_Guide[0] ) # find the parents system type
- Parent_Guide_Extra_Type = RigBox_ReadExtraTypeAtr( FindParent_Guide[0] )
- TestParent_Guide_Local_Type = ( Parent_Guide_Extra_Type is Extra_Types[1] ) # is the parent guide type a local?
- pass #printing the known values!
- print ( 'Pin system: \n' + 'Pinning: ' + x + '\n pin = ' + Pin_Master + ' to ' + FindParent_Guide[0] + '\n type =' + Parent_Guide_System_Type + '\n' )
- pass # new system mothaf**ker
- Guide_System_Type = RigBox_ReadSystemTypeAtr( x ) # find the parents system type
- Guide_Extra_Type = RigBox_ReadExtraTypeAtr( x )
- if Guide_System_Type == 'IK': #item is ik
- if Parent_Guide_System_Type == 'FK': #and parent is fk..
- if TestParent_Guide_Local_Type is True: #and parent has local fk control... cons to that instead..
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )
- if TestParent_Guide_Local_Type is False: #or not..
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == '_':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'PoleV':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'Aim_Target':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'Aim_Affected':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Guide_System_Type == 'FK': #item is fk only
- if Parent_Guide_System_Type == 'FK': #items parent is fk, just cons as normal (ignore local)
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'IK': #items parent is fk, just cons as normal (ignore local)
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'IK' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'IKFK': #items parent is IKFK, need to switch between all cases..
- RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[3] ) , ( FindParent_Guide[0] + '_Control_FK' ) , 'UseCons' , True )
- cmds.connectAttr( ( FindParent_Guide[0] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0] ) )
- if Parent_Guide_System_Type == '_':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'PoleV':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'Aim_Target':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'Aim_Affected':
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- if Guide_System_Type == 'IKFK': #item is IKFK type..
- if Parent_Guide_System_Type == 'FK': #items parent is fk, just cons as normal (ignore local)
- if TestParent_Guide_Local_Type is True: #and parent has local fk control... cons to that instead..
- RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , ( FindParent_Guide[0] + '_Control_' + 'FK' ) , 'UseCons' , True )
- cmds.connectAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0] ) )
- if TestParent_Guide_Local_Type is False: #and parent has local fk control... cons to that instead..
- cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
- if Parent_Guide_System_Type == 'IKFK': #items parent is IKFK, need to switch between all cases..
- RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , ( FindParent_Guide[0] + Suffix_Joints[1] ) , 'UseCons' , True )
- cmds.connectAttr( ( x + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[1] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0] ) )
- # if Parent_Guide_System_Type == 'FK': #items parent is fk, just cons as normal (ignore local)
- # if TestParent_Guide_Local_Type is True: #and parent has local fk control... cons to that instead..
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_Local_' + 'FK' ) , Pin_Master , mo = True )
- # if TestParent_Guide_Local_Type is False: #or not..
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
- # if Parent_Guide_System_Type == 'IK': #items parent is IK, just cons as normal (ignore local)
- # pass
- # pass # create the blended pin!
- # if Guide_System_Type_Current == 'FK': #and parent is FK type..
- # RigBox_Blend_2_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , 'UseCons' , True )
- # if Guide_System_Type_Current == 'IKFK':
- # RigBox_Blend_3_Items( Pin_Master , ( FindParent_Guide[0] + '_Control_IK' ) , ( FindParent_Guide[0] + '_Control_FK' ) , 'UseCons' , True )
- # cmds.connectAttr( ( FindParent_Guide[0] + Suffix_Joints[0] + '.' + IK_FK_Blend_Atr[0] ) , ( Pin_Master + '.' + IK_FK_Blend_Atr[0] ) )
- # if Guide_System_Type_Current == 'IK':
- # RigBox_Blend_2_Items( Pin_Master , ( FindParent_Guide[0] + Suffix_Joints[0] ) , 'UseCons' , True )
- # 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.
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'IK' ) , Pin_Master , mo = True )
- #need to break the ik and ikfk starts to follow the local control instead of the immediate parent.
- # if Parent_Guide_System_Type == 'FK': # suspicious look at.
- # pass # need to run a test for local fk control type!
- # if TestParent_Guide_Local_Type is True:
- # 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.
- # if TestParent_Guide_Local_Type is False:
- # 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.
- # if TestGuide_Extra_Type is True:
- # 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.
- # else:
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control_' + 'FK' ) , Pin_Master , mo = True )
- # if Guide_System_Type == '_':
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- # if Guide_System_Type == 'PoleV':
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- # if Guide_System_Type == 'Aim_Target':
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- # if Guide_System_Type == 'Aim_Affected':
- # cmds.parentConstraint( ( FindParent_Guide[0] + '_Control' ) , Pin_Master , mo = True )
- # print '---[[[[[[[[[ End Pinning System ]]]]]]]]]---\n'
- def RigBox_SpaceSwitching_list():
- Pin_Types_Found =[ [] ] * len( Pin_Types )
- count = 0
- for x in Pin_Types: # filling in the list with a list of the current options available.
- Pin_Types_Found[ count ] = [ Pin_Types[ count ] ]
- count+=1
- All_Guides = RigBox_FindAll( 'Guide' ) # grab all guides to begin with..
- for x in All_Guides:
- pass # grab each pin type.
- Type = RigBox_ReadPinTypeAtr( x )
- Type_Int = RigBox_List_To_Value( Pin_Types , Type )
- if Type_Int > 0:
- pass # fill in the list with the guide objects found..
- Pin_Types_Found[ Type_Int ].append( x )
- return Pin_Types_Found
- def RigBox_SpaceSwitching(): # sets up the space switching constraints and attributes.
- Pin_Types_Found = RigBox_SpaceSwitching_list()
- for x in Pin_Types_Found:
- if len( x ) is 1:
- pass
- if len( x ) > 1: # something to constrain up?
- print 'Starting Space Switch Mode/Section:'
- Items = x[1:]
- Type = x[0]
- if Type is Pin_Types[1]:
- pass
- else:
- for Item in Items:
- pass # is the item IK IKFK OR FK? fk shouldnt receive space switching treatment.
- Guide_System_Type = RigBox_ReadSystemTypeAtr( Item ) # find the parents system type
- # if Guide_System_Type == '67':
- if Guide_System_Type == 'FK':
- pass
- else:
- FakeTests = [ 'boob' ]
- GrpToBeControlled = ''
- ControlToBeEdited = ''
- for FakeTest in FakeTests:
- TestExist = cmds.ls( ( Item + '_Control_Grp' ) )
- if len( TestExist ) > 0:
- print TestExist
- GrpToBeControlled = TestExist
- ControlToBeEdited = ( Item + '_Control' )
- break
- TestExist_IK = cmds.ls( ( Item + '_Control_IK_Grp' ) )
- if len( TestExist_IK ) > 0:
- print TestExist_IK
- GrpToBeControlled = TestExist_IK
- ControlToBeEdited = ( Item + '_Control_IK' )
- break
- TestExist_FK = cmds.ls( ( Item + '_Control_FK_Grp' ) )
- if len( TestExist_FK ) > 0:
- print TestExist_FK
- GrpToBeControlled = TestExist_FK
- ControlToBeEdited = ( Item + '_Control_FK' )
- break
- print 'testinggee'
- print Item
- print GrpToBeControlled
- print ControlToBeEdited
- print '\n'
- Test = cmds.parentConstraint( GrpToBeControlled , q = True )
- if Test is None:
- pass # find the type in the global list to get the index value..
- Type_Int = RigBox_List_To_Value( Pin_Types , Type )
- Goals_To_Constrain_To = Pin_Type_Targets[ Type_Int ]
- print '\n Space Switch Mode: '
- print 'Item: ' + Item
- print 'Being constrained to: '
- print Goals_To_Constrain_To
- print '\n'
- Targets_Type_Found = []
- Targets_Actually_Found = []
- for Goal in Goals_To_Constrain_To:
- pass # print Goal
- test = RigBox_List_To_Value( Pin_Types , Goal )
- if test is None:
- pass
- else:
- tmp = Pin_Types_Found[ RigBox_List_To_Value( Pin_Types , Goal )]
- print tmp
- Targets_Found = tmp[1:]
- for Targets in Targets_Found:
- pass # setup the constraints in order..
- Target = None
- Tmp = [ 'bla' ]
- for T in Tmp:
- Test_Control_IK = cmds.ls( ( Targets + '_Control_IK' ) )
- if Test_Control_IK is None:
- pass
- if len( Test_Control_IK ) > 0:
- Target = Test_Control_IK
- break
- Test_Control = cmds.ls( ( Targets + '_Control' ) )
- if Test_Control is None:
- pass
- if len( Test_Control ) > 0:
- Target = Test_Control
- break
- Test_Control_FK = cmds.ls( ( Targets + '_Control_FK' ) )
- if Test_Control_FK is None:
- pass
- if len( Test_Control_FK ) > 0:
- Target = Test_Control_FK
- break
- pass # keep the joint search last, causes constraint loop if first.. need to fix!!!!
- Test_Jnt = cmds.ls( ( Targets + Suffix_Joints[0] ) )
- if Test_Jnt is None:
- pass
- if len( Test_Jnt ) > 0:
- Target = Test_Jnt
- break
- if Target is None:
- break
- else:
- print Target
- print GrpToBeControlled
- cmds.parentConstraint( Target , GrpToBeControlled , w = 0.0 , mo = True )
- Targets_Actually_Found.append( Target[0] )
- Targets_Type_Found.append( Targets )
- print ControlToBeEdited
- pass # add the attribute here:
- Parent_Types_Flat = Split_Char.join( Targets_Actually_Found )
- cmds.addAttr( ControlToBeEdited , shortName = ( 'Follow' ) , at = 'enum' , en = Parent_Types_Flat ) #add it to node
- cmds.setAttr( ( ControlToBeEdited + '.' + 'Follow' ) ) #set the correct value
- cmds.setAttr( ( ControlToBeEdited + '.' + 'Follow' ) , channelBox =True , keyable= True ) #add it to node
- cmds.setAttr( ( ControlToBeEdited + '.' + 'Follow' ) , keyable = True ) #add it to node
- pass # Now to setup the set driven keys..
- Name_Of_Cons_O = cmds.parentConstraint( GrpToBeControlled , query = True ) #gets the name of the constraint
- Cons_Targets = cmds.parentConstraint( GrpToBeControlled , query = True , tl = True ) #gets the name of the constraint
- count = 0
- for type_item in Targets_Actually_Found:
- cmds.setAttr( ( ControlToBeEdited + '.' + 'Follow' ) , count ) #add it to node
- Counters = 0
- for Targets in Cons_Targets:
- cmds.setAttr( ( Name_Of_Cons_O + '.' + Targets + 'W' + str( Counters ) ) , 0 ) #add it to node
- Counters+=1
- cmds.parentConstraint( Cons_Targets[ count ] , GrpToBeControlled , e = True, w = 1.0 )
- driver = ( ControlToBeEdited + '.' + 'Follow' )
- counter = 0
- while counter < len( Targets_Actually_Found ):
- cmds.setDrivenKeyframe( ( Name_Of_Cons_O + '.' + Targets_Actually_Found[counter] + 'W' + str(counter) ) , cd= driver )
- counter+=1
- count+=1
- cmds.setAttr( ( ControlToBeEdited + '.' + 'Follow' ) , 0 ) #add it to node
- def RigBox_Frz_Vis_All():
- global All_Controls_Made
- print 'starting vis freeze all'
- print All_Controls_Made
- for controls in All_Controls_Made:
- cmds.setAttr( ( controls + '.v' ) , lock = True , keyable = False , channelBox = False )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement