Notifications
Clear all

[Closed] Animate Button press….?

I’ve been hunting through the maxscript and i’m not certain if this is possible but…I have a dialog box with some buttons and basically it links the selected objects together, this all works fine but I need to animate the checkbutton presses so it sets a keyframe of the checkbutton being pressed each time… like an animated switch…Not sure how to clarify this any more…

5 Replies

Why not just use a spinner with a range integer range of 0 – 1. It will do the same thing, if I understood you correctly, and its a fairly simple setup.

1 Reply
(@electricbones)
Joined: 11 months ago

Posts: 0

I’ve been trying that but the slider isn’t being keyframed either. my test set up is a simple one. 3 boxes… set 1 to the master and with the toggle switch(spinner) turn it’s effects on or off and the other 2 are set to slaves.
On = I move the master and the other 2 follow. if I keyframe the master’s movement across the screen with the link turned on the slaves follow but halfway through I want to switch off the link so only the master moves the remaining distance. is that a bit clearer?

I may have to over complicate it to get it working but i’m sure there must be a more simple way than setting it to auto keyframe the position of the slaves when the master is moved if the button is active. sorry this is a little complex

you could write something like this:


(
	for T = 0 to 100 do (	--loop through a (frame)range
		sliderTime = (T)	--sets the timeSlider to the current iterration Integer

                -- here comes your animation

	)

)

there also is an “with animate on” context you can use but this bugged out on me a few times so i use the method above

are you using a link constraint, or a scripted controller, reaction controller, to get the boxes to follow? A reaction controller set to the switch might do what you need if its for simple transformations. Have the boxes follow as the switch is set to 1, then they do not react when set to 0. Unless you really need keyframes on the slaves. If so you can always bake the animation after your done setting it all up.

To be hoenst I’m cutting corners and using the parent system which I’m beginning to realise may not have been the best way lol. here is my current code…

macroScript HoldObjectUI
	Category:"myOwnScripts"
	
(
-------------------------------------------------------------------------------------------------------
--Declaration of variables.
--The makeLeg functions call a seperate script file depending on the chosen option of leg rig.
-------------------------------------------------------------------------------------------------------
	
	RigDialog = newRolloutFloater "IK Object" 200 250
------------------------------------------------------------------------------------------------	
--Start of Connector rollout. Functions act as a filter for pick button geometry type.
------------------------------------------------------------------------------------------------
	
rollout rollIKObject "Hold Objects"
	(	
		groupbox IKObjectbox "Select the hand and object" pos: [10,10] width: 165 height: 190
		Label labpick1 "Select the Object" pos: [50,115]
		Label labpick2 "Select the Wrist Controllers" pos: [30,30]
		pickbutton pickParent "Object" pos: [32,140] 
		pickbutton pickChild "Select" pos: [37,55] 
		pickbutton pickChild2 "Select" pos: [35,85] 
		checkbutton btntoggleLink "Toggle Link" pos: [55,170] enabled: false animButtonEnabled: True
		button btnclearchild1 "Clear" pos:  [110,55]
		button btnclearchild2 "Clear" pos:  [110,85]
		button btnclearparent "Clear" pos:  [110,140]


		on pickParent picked parent do
		( 
			if parent != undefined do
		
			pickParent.text = parent.name
			select(parent)
			
			if  pickParent.object != undefined then
			(if pickChild.object != undefined then
				(btntoggleLink.enabled = true))
		)	--end of pickParent IF expression
		
		on pickChild picked child do
		( 
			if child != undefined do
		
			pickChild.text = child.name
			select(child)
			
			if  pickParent.object != undefined then
			(if pickChild.object != undefined then
				(btntoggleLink.enabled = true))
		)	--end of pickChild IF expression

		on pickChild2 picked child2 do
		( 
			if child2 != undefined do
		
			pickChild2.text = child2.name
			select(child2)
			
			if  pickParent.object != undefined then
			(if pickChild2.object != undefined then
				(btntoggleLink.enabled = true))
		)	--end of pickChild IF expression
		

		on btntoggleLink changed state do

			(	if state == on then
				
				(if pickChild.object != undefined then
					
				pickChild.object.parent = pickParent.object
				
				if pickChild2.object != undefined then
					
				pickChild2.object.parent = pickParent.object)
				
				if state == off then
					
				(if PickChild.object.parent == undefined
					then 
					PickChild.object.parent = undefined
					else
					PickChild.object.parent = undefined
					
				if PickChild2.object.parent == undefined
					then
					PickChild2.object.parent = undefined
					else
					PickChild2.object.parent = undefined)
			)
		
		on btnclearchild1 pressed do
			(pickChild.Object = undefined
			pickChild.text = "Select")
		
		on btnclearchild2 pressed do
			(pickChild2.Object = undefined
			pickChild2.text = "Select")
		
		on btnclearparent pressed do
			(pickParent.Object = undefined
			pickParent.text = "Select")
		
	)--end of rollout


		
addrollout rollIKObject RigDialog
	
)