if Rig_Tools != undefined do ( closerolloutfloater Rig_Tools ) Rig_Tools = newrolloutfloater "Rig Tools" 520 140 rollout IK_FK_Arm "Create IK/FK Arm Setup" --width:504 height:112 ( pickbutton btn1 "UpperArm =" pos:[24,48] width:143 height:32 pickbutton btn2 "ForeArm =" pos:[176,48] width:143 height:32 pickbutton btn3 "Hand =" pos:[328,40] width:72 height:48 button btn4 "- Go -" pos:[424,48] width:47 height:32 groupBox grp1 "Build IK-FK Arm" pos:[8,8] width:488 height:96 function ErrorCheck Segment1 Segment2 Segment3 = ( if not (QueryBox "You cannot undo this action.\n\nThis script is name object dependant.\nPlease make sure your bones are named correctly before proceeding.\nYou cannot rename any bones after you have run the setup.\n\nProceed?" title:"Proceed?") do return false if Segment3.parent != Segment2 do return false if Segment2.parent != Segment1 do return false return true ) on btn1 picked obj do ( if obj != undefined do ( btn1.text = obj.name ) ) on btn2 picked obj do ( if obj != undefined do ( btn2.text = obj.name ) ) on btn3 picked obj do ( if obj != undefined do ( btn3.text = obj.name ) ) on btn4 pressed do ( --Get the Arm Nodes Upper = getNodeByName btn1.text Fore = getNodeByName btn2.text Hand = getNodeByName btn3.text if ErrorCheck Upper Fore Hand do ( --Snapshot and name, and parent the IK Arm a = snapshot (Upper) a.name = ("IK_" + btn1.text) b = snapshot (Fore) b.name = ("IK_" + btn2.text) c = snapshot (Hand) c.name = ("IK_" + btn3.text) g = snapshot (Hand) g.name = ("Controller_" + btn3.text) c.parent = b b.parent = a if upper.parent != undefined do a.parent = Upper.parent g.parent = undefined --Snapshot and name, and parent the FK Arm d = snapshot (Upper) d.name = ("FK_" + btn1.text) e = snapshot (Fore) e.name = ("FK_" + btn2.text) f = snapshot (Hand) f.name = ("FK_" + btn3.text) f.parent = e e.parent = d if upper.parent != undefined do d.parent = Upper.parent --Create a helper for the FK Bones Swivel Target to follow LookAtHelper = point() LookAtHelper.name = (Upper.name + "_LookAt_NULL") PosCon = Position_Constraint() LookAtHelper.position.controller = PosCon PosCon.constraints.appendTarget d 50 PosCon.constraints.appendTarget f 50 RotCon = LookAt_Constraint() LookAtHelper.rotation.controller = RotCon RotCon.constraints.appendTarget e 50 RotCon.lookat_vector_length = 0 RotCon.upnode_world = false RotCon.PickUpnode = d --Setup the FK Swivel Target FkSwivel = point() FKSWivel.name = (Upper.name + "_FkSwivel_NULL") FkSwivel.transform = LookAtHelper.transform in coordsys local ( Offset = (distance a b) + (distance b c) + 5 move FkSwivel [Offset,0,0] ) FkSwivel.parent = LookAtHelper --Setup Link Constraint on the IK Hand Controler gTempTrans = g.Transform g.Transform.controller = Link_Constraint () g.transform.controller.addWorld FrameNo:-9999 g.Transform = gTempTrans --Setup the IK Stuff IKHandle = ikSys.ikChain a c "IkLimb" IKSwivelHelper = point() IKSwivelHelper.name = (Upper.name + "_Target") IKSwivelHelper.cross = off IKSwivelHelper.Box = on IKSwivelHelper.transform = FkSwivel.Transform IKHandle.transform.controller.VHTarget = IKSwivelHelper IKHandle.transform.controller.useVHTarget = true IkPosCon = Position_Constraint() IKHandle.position.controller = IkPosCon IkPosCon.constraints.appendTarget g 50 IkRotCon = Orientation_Constraint() c.rotation.controller = IkRotCon c.rotation.controller.appendTarget g 50 --Setup the Original Arm RotConstratints UpperRotCon = Orientation_Constraint() Upper.rotation.controller = UpperRotCon Upper.rotation.controller.appendTarget a 100 Upper.rotation.controller.appendTarget d 0 ForeRotCon = Orientation_Constraint() Fore.rotation.controller = ForeRotCon Fore.rotation.controller.appendTarget b 100 Fore.rotation.controller.appendTarget e 00 HandRotCon = Orientation_Constraint() Hand.rotation.controller = HandRotCon Hand.rotation.controller.appendTarget c 100 Hand.rotation.controller.appendTarget f 0 --Configure Visibility, Freeze, Wirecolor, and Lock options --Freeze Color off select #(Upper,Fore,Hand,a,b,c,e,f,g,LookAtHelper,FkSwivel,IKHandle,IKSwivelHelper) for obj in selection do ( obj.showFrozenInGray = False ) --FK WireColor select #(d,e,f) max box mode selected selection.wirecolor = color 148 177 26 --Grey Items select #(a,b,c,LookAtHelper,FkSwivel) selection.wirecolor = color 115 115 115 --IK colors select #(g,IKSwivelHelper) selection.wirecolor = Hand.wirecolor --Hide FK Default. Also We never show IK bones, just the controller. select #(a,b,c,d,e,f,LookAtHelper,FkSwivel,IKHandle) max hide selection --Create and Add the Attribute Holder Modifier AttributeHolderMod = EmptyModifier() select #(a,b,c,d,e,f,g,Upper,Fore,Hand,IKHandle,IKSwivelHelper) modPanel.addModToSelection AttributeHolderMod ui:on --Freeze and Lock stuff select #(a,b,c,Hand,Upper,Fore,LookAtHelper,IKHandle,FkSwivel) setTransformLockFlags selection #all max freeze selection --Set Skin Pose on the animatable controllers d.setSkinPose() e.setSkinPose() f.setSkinPose() g.setSkinPose() IKSwivelHelper.setSkinPose() --Select the IK controller select #(g) ---------------------------------------- -- Define CA and add them to a Modifier ---------------------------------------- node_ca = attributes node_attribs ( parameters node_params ( 'Upper' type:#string 'Fore' type:#string 'Hand' type:#string 'a' type:#string 'b' type:#string 'c' type:#string 'd' type:#string 'e' type:#string 'f' type:#string 'g' type:#string 'FKSwivel' type:#string 'LookAtHelper' type:#string 'IKSwivelHelper' type:#string ) ) custAttributes.add AttributeHolderMod node_ca --Assign the Nodes to the node_ca attribute (custAttributes.get AttributeHolderMod 1).Upper = Upper.name (custAttributes.get AttributeHolderMod 1).Fore = Fore.name (custAttributes.get AttributeHolderMod 1).Hand = Hand.name (custAttributes.get AttributeHolderMod 1).a = a.name (custAttributes.get AttributeHolderMod 1).b = b.name (custAttributes.get AttributeHolderMod 1).c = c.name (custAttributes.get AttributeHolderMod 1).d = d.name (custAttributes.get AttributeHolderMod 1).e = e.name (custAttributes.get AttributeHolderMod 1).f = f.name (custAttributes.get AttributeHolderMod 1).g = g.name (custAttributes.get AttributeHolderMod 1).FKSwivel = FKSwivel.name (custAttributes.get AttributeHolderMod 1).LookAtHelper = LookAtHelper.name (custAttributes.get AttributeHolderMod 1).IKSwivelHelper = IKSwivelHelper.name ikfk_ca = attributes ikfk_attribs ( parameters ikfk_params rollout: ikfk_roll ( 'ikfk_blend' type:#float ui:ikfk_slider animatable:true ) rollout ikfk_roll "IK-FK Options" ( slider ikfk_slider "IK-FK Blend:" range:[0,100,0] ticks:0 group "Show/Hide:" ( button hide_fk "Toggle FK" across:2 width: 65 button hide_ik "Toggle IK" width: 65 ) group "Match:" ( button match_fk "Align FK" across:2 width: 65 button match_ik "Align IK" width: 65 ) group "Set Limb Key:" ( button key_fk "Key FK" across:2 width: 65 button key_ik "Key IK" width: 65 button key_zero "Zero Out" across:2 height: 35 width: 65 button key_all "Key All" height: 35 width: 65 ) on key_fk pressed do ( undo "Key FK" on ( addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).rotation.controller (SliderTime) ) ) on key_ik pressed do ( undo "Key IK" on ( addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).rotation.controller (SliderTime) ) ) on key_zero pressed do ( undo "Zero Out" on ( with animate on ( (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).assumeSkinPose() (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).assumeSkinPose() (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).assumeSkinPose() (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).assumeSkinPose() (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).assumeSkinPose() ) ) ) on key_all pressed do ( undo "Key All" on ( addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).rotation.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).pos.controller (SliderTime) addNewKey (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).rotation.controller (SliderTime) ) ) on match_fk pressed do ( undo "Match FK" on ( with animate on ( (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d).transform = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).a).transform (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e).transform = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).b).transform (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).transform = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).c).transform ) ) ) on match_ik pressed do ( undo "Match IK" on ( with animate on ( (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).transform (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper).transform = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).FKSwivel).transform ) ) ) on hide_fk pressed do ( if (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f).isHidden then ( unhide #((getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f)) ) else ( hide #((getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).d),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).e),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).f),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).FKSwivel),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).LookAtHelper)) ) ) on hide_ik pressed do ( if (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).isHidden then ( unhide #((getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper)) ) else ( hide #((getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).a),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).b),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).c),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g),(getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).IKSwivelHelper)) ) ) ) ) custAttributes.add AttributeHolderMod ikfk_ca NewStuff = attributes NewAttributes ( Parameters main rollout:params ( 'btn1' Type:#node UI:'btn1' ) rollout Params "Ik Parent Constraint" width:184 height:296 ( groupBox grp1 "Frame # - Target" pos:[4,112] width:150 height:144 listBox lbx1 "" pos:[10,128] width:138 height:9 spinner spn1 "Start Time:" pos:[36,264] width:101 height:16 range:[-9999,9999,0] type:#integer pickButton btn1 "Add Link" pos:[8,16] width:142 height:24 button btn2 "Link to World" pos:[8,48] width:142 height:24 button btn3 "Delete Link" pos:[8,80] width:142 height:24 function BuildLbx1Array = ( --Build lbx1 Array lbx1.items = #() for i = 1 to ((getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.getNumTargets()) do ( ItemString = "" FrameNumber = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.getFrameNo i N = (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.getNode i if N == undefined then ( ItemString = (FrameNumber as string) + " - World" ) else ( ItemString = (FrameNumber as string) + " - " + N.name ) append lbx1.items ItemString lbx1.items = lbx1.items ) ) on Params open do ( --Now a function because sorting is stupid (This way is better anyway). BuildLbx1Array() ) on btn1 picked obj do ( --Add OBJ to Link Constraint, update lbx1 set animate on (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.addTarget obj (SliderTime) BuildLbx1Array() ) on btn2 pressed do ( --Add World to Link Constarint, update lbx1 set animate on (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.addWorld BuildLbx1Array() ) on btn3 pressed do ( --Delete selected lbx1 item, update lbx1 if lbx1.selection != 0 do ( (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.DeleteTarget lbx1.selection BuildLbx1Array() ) ) on spn1 changed val do ( --Change selected lbx1 item, update lbx1 if lbx1.selection != 0 do ( set animate on ItemString = "" (getNodeByName (custAttributes.get selection[1].Attribute_Holder 1).g).transform.controller.setFrameNo (lbx1.selection) (val) BuildLbx1Array() ) ) ) ) custAttributes.add AttributeHolderMod NewStuff -- Let's Wire the Paramters paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Upper.rotation.controller[#Orientation_Weight_0] "100-(ikfk_blend)" paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Upper.rotation.controller[#Orientation_Weight_1] "ikfk_blend" paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Fore.rotation.controller[#Orientation_Weight_0] "100-(ikfk_blend)" paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Fore.rotation.controller[#Orientation_Weight_1] "ikfk_blend" paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Hand.rotation.controller[#Orientation_Weight_0] "100-(ikfk_blend)" paramWire.connect AttributeHolderMod.ikfk_attribs[#ikfk_blend] Hand.rotation.controller[#Orientation_Weight_1] "ikfk_blend" ) ) ) rollout LegSetup "Create Legs Setup" width:504 height:112 ( ) rollout RigAbout "Rig Tools" width:504 height:112 ( ) addRollout IK_FK_Arm Rig_Tools addRollout LegSetup Rig_Tools rolledUp:True addRollout RigAbout Rig_Tools rolledUp:True