Notifications
Clear all

[Closed] FK-IK snap script running backwards ???

I’m at my wits end on this one.

If I run this code in isolation (select and execute), it does what I expect:

			
$ctrl_FK_r_leg_a.transform = $IK_r_leg_a.transform
$ctrl_FK_r_leg_b.transform = $IK_r_leg_b.transform
$ctrl_FK_r_foot.transform = $IK_r_foot.transform

the FK ctrls snap to the IK bones.

and yet when I embed this as a fucntion on a button, the opposite happens!
the IK bones snap to the FK controls objects.

further strangeness : the same script with different object names works flawlessly on the arms…

I can’t even guess what the heck is happening here…

4 Replies

there is a bug in your code or the bones are named wrong. it’s very hard to say anything more without seeing any details. if you want to get the real help post the code, make scene setup, etc.

Further investigation indicates this is a result of wrapping the function inside of a checkButton.

parameters ikfk_params rollout: ikfk_roll
	(
		'bool_ik' type:#boolean  animatable:true 
	)

rollout ikfk_roll "IK-FK Options"
	(
		fn snapToIK =(
			print "SnaptoIK..."
			$ctrl_FK_r_leg_a.transform = $IK_r_leg_a.transform
			$ctrl_FK_r_leg_b.transform = $IK_r_leg_b.transform
			$ctrl_FK_r_foot.transform = $IK_r_foot.transform
		)
	 
		fn snapToFK=(
			print "snaptoFK..."
			$ctrl_IK_r_foot.transform =$ctrl_FK_r_foot.transform
			$IK_r_leg_swivel.transform= $FK_r_leg_swivel.transform
		)
		
		checkbutton btn_fk_on "FK" highlightColor:red checked:(not (bool_ik)) across:2 
		checkbutton btn_ik_on "IK"  highlightColor:green checked: bool_ik
		
		on btn_ik_on  changed state  do(
				bool_ik = true
				btn_fk_on.checked=false
				snapToFK()
				select $ctrl_IK_r_foot
			)
		
		on btn_fk_on  changed state  do(
			bool_ik =false
			btn_ik_on.checked=false
			snapToIK()
		)
	)

I’ve got it working by abandoning function calls and checkbuttons all together for FK snap, instead wrapping the code in a simple button.

		

button btn_snapToIK "FK" 
		on btn_snapToIK pressed do(
			$ctrl_FK_r_leg_a.transform = $IK_r_leg_a.transform
			$ctrl_FK_r_leg_b.transform = $IK_r_leg_b.transform
			$ctrl_FK_r_foot.transform = $IK_r_foot.transform
			btn_ik_on.checked=false
			bool_ik=false
		)

But I still have no clue why the function in the first case fails, yet the second function snapToFK works fine. the fact that the hack works tells me it’s the code and not the rig -but even so I have double a triple checked the names.

Chances are I am just not using the check button correctly…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i think the IK solver settings “IK for FK Pose” and “Auto Snap” work against.

The culprit was inconsistent bone orientation between arms and legs.

the arms were set up fully for mirrored axes

the legs were not

the result was incorrect trasnform data.

bone orientation problem detailed in this thread