PDA

View Full Version : change text on button pressed not work with undo


LaMiKrA
12-10-2011, 03:05 PM
I have this script to change the name of the button when it's pressed but not work with undo!
please i need a review . Thanks.

text1 = Btn_Snap.text
if text1 == "IK" then
(
Btn_Snap.text = "FK"
)
else Btn_Snap.text = "IK"

Bobo
12-10-2011, 05:08 PM
I have this script to change the name of the button when it's pressed but not work with undo!


If you mean the 3ds Max Undo buffer, it only tracks scene changes.
There is no way to record the change of a button text via the Undo buffer.

The only case I could imagine where this would work would be if the button was showing a parameter of a scene object and you were using callbacks to track changes to that object and update the button's text.

LaMiKrA
12-10-2011, 06:12 PM
ouch!, thanks Bobo by request, so do you think if i could use the blending spinner parameter to do something like that without callbacks? for example if the spinner state is 100 do text1 and if the spinner is 0 do text2? sorry about my ignorance, im learning now maxscript and i like search my own requests but this is anything that appears easy and useful for show the state of my IK/FK button mode but... thanks!

miauu
12-11-2011, 12:54 PM
rollout rol_ ""
(
button btn_1 "TEXT"
spinner spn_1 ""

on spn_1 changed val do
(
if val == 100 do btn_1.text = "Text 1"
if val == 0 do btn_1.text = "Text 0"
)
)
createdialog rol_

LaMiKrA
12-11-2011, 06:12 PM
I'm very gratfeul Miauu nice nice nice!

LaMiKrA
01-05-2012, 11:59 PM
Ok, now the problem is: I want to use it in a snap IK FK button, so the value may change when the snap button is pressed not when the spinner value is changed. I have prove this lines in my snap button but not work. any idea?
Here is the snap code, it's a normal snap code with case and value events


on Btn_Snap pressed do
with undo on
(


case $.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value of

(
100.0:
(

--MATCH BUTTON FK TO IK--
------------------------------------------------------------------------------------------------------------------------------------------
--CUANDO PASO A FK--

--Set keys in actual and previews frame
sliderTime -= 1

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Fk_Ik = 100

sliderTime += 1

--SET FK / IK SPINNER VALUE TO 0 = FK

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value=0


--ALIGN FK TO IK--


--Set Shoulder orientation control to IK

in coordsys $ST_Arm_Bone_IK_01_L$ST_Arm_Ctrl_Shoulder_L.rotation = eulerangles 0 0 0


--Set Elbow orientation control to IK

in coordsys $ST_Arm_Bone_IK_02_L$ST_Arm_Ctrl_Elbow_L.rotation = eulerangles 0 0 0


--Align hand orientation to wrist IK control

in coordsys $ST_Arm_Ctrl_Ik_L$ST_Arm_Hand_Root_FK_L.rotation = eulerangles 0 0 0

--Hide unhide controls


hide $ST_Arm_Ctrl_Ik_L
unhide $ST_Arm_Ctrl_Elbow_L
unhide $ST_Arm_Ctrl_Shoulder_L
unhide $ST_Arm_Hand_Root_FK_L


)

0.0:
(

--ALINEA LA IK A LA FK
-------------------------------------
--CUANDO PASO A IK

--Set keys in actual and previews frame

sliderTime -= 1

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Fk_Ik = 0

sliderTime += 1

--SET FK / IK SPINNER VALUE TO 0 = IK

if $.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Up_Stretch > 0 then
(
messagebox "Cannot switch to IK with FK stretched"

)
else

(
--Set wrist position control IK to FK
$ST_Arm_Ctrl_Ik_L.position = $ST_Arm_Point_Strch_FK_03_L.position

--Align Fk wrist control to IK

in coordsys $ST_Arm_Hand_Root_FK_L$ST_Arm_Ctrl_Ik_L.rotation = eulerangles 0 0 0

--Align Swivel IK to FK

$ST_Arm_SwivelAngle_IK_L.position = $ST_Arm_SwivelAngle_Align_FK_L.position

--Align control IK to Hand root

in coordsys $ST_Arm_Hand_Root_FK_L$ST_Arm_Ctrl_Ik_L.rotation = eulerangles 0 0 0



--Align swivel control



--Set FK / IK spinner to 100

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value=100










--Hide Unhide controls
hide $ST_Arm_Hand_Root_FK_L
hide $ST_Arm_Ctrl_Elbow_L
hide $ST_Arm_Ctrl_Shoulder_L
unhide $ST_Arm_Ctrl_Ik_L
)

)
)
)

miauu
01-06-2012, 04:55 AM
In the last code - what the button should show as a text - sliderTime values or case off values?
If the text must be sliderTime values put this after each sliderTime = +/-1

Btn_Snap.text = sliderTime.time as string
Maybe you want this:
on Btn_Snap pressed do
with undo on
(


case $.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value of

(
100.0:
(
Btn_Snap.text = "100.0"
--MATCH BUTTON FK TO IK--
------------------------------------------------------------------------------------------------------------------------------------------
--CUANDO PASO A FK--

--Set keys in actual and previews frame
sliderTime -= 1
Btn_Snap.text = sliderTime.time as string
$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Fk_Ik = 100

sliderTime += 1
Btn_Snap.text = sliderTime.time as string
--SET FK / IK SPINNER VALUE TO 0 = FK

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value=0


--ALIGN FK TO IK--


--Set Shoulder orientation control to IK

in coordsys $ST_Arm_Bone_IK_01_L$ST_Arm_Ctrl_Shoulder_L.rotati on = eulerangles 0 0 0


--Set Elbow orientation control to IK

in coordsys $ST_Arm_Bone_IK_02_L$ST_Arm_Ctrl_Elbow_L.rotation = eulerangles 0 0 0


--Align hand orientation to wrist IK control

in coordsys $ST_Arm_Ctrl_Ik_L$ST_Arm_Hand_Root_FK_L.rotation = eulerangles 0 0 0

--Hide unhide controls


hide $ST_Arm_Ctrl_Ik_L
unhide $ST_Arm_Ctrl_Elbow_L
unhide $ST_Arm_Ctrl_Shoulder_L
unhide $ST_Arm_Hand_Root_FK_L


)

0.0:
(
Btn_Snap.text = "0.0"
--ALINEA LA IK A LA FK
-------------------------------------
--CUANDO PASO A IK

--Set keys in actual and previews frame

sliderTime -= 1
Btn_Snap.text = sliderTime.time as string
$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Fk_Ik = 0

sliderTime += 1
Btn_Snap.text = sliderTime.time as string
--SET FK / IK SPINNER VALUE TO 0 = IK

if $.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS.Spn_Up_Stretch > 0 then
(
messagebox "Cannot switch to IK with FK stretched"

)
else

(
--Set wrist position control IK to FK
$ST_Arm_Ctrl_Ik_L.position = $ST_Arm_Point_Strch_FK_03_L.position

--Align Fk wrist control to IK

in coordsys $ST_Arm_Hand_Root_FK_L$ST_Arm_Ctrl_Ik_L.rotation = eulerangles 0 0 0

--Align Swivel IK to FK

$ST_Arm_SwivelAngle_IK_L.position = $ST_Arm_SwivelAngle_Align_FK_L.position

--Align control IK to Hand root

in coordsys $ST_Arm_Hand_Root_FK_L$ST_Arm_Ctrl_Ik_L.rotation = eulerangles 0 0 0



--Align swivel control



--Set FK / IK spinner to 100

$.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value=100










--Hide Unhide controls
hide $ST_Arm_Hand_Root_FK_L
hide $ST_Arm_Ctrl_Elbow_L
hide $ST_Arm_Ctrl_Shoulder_L
unhide $ST_Arm_Ctrl_Ik_L
)

)
)
)
Or maybe not.

Panayot
01-06-2012, 08:10 PM
Btn_Snap.text = sliderTime as text -- ? not possible conversion
probably you mean sliderTime.time as String

miauu
01-06-2012, 08:21 PM
Yes! Thanks for the correction. :)
I fixed the errors in code above.

LaMiKrA
01-06-2012, 10:11 PM
Thanks for reply, sorry I could have better explained..
The slider time lines its only a proccess in the code that generates the keys for the snap button to avoid them by hand. I have a button with the snap and the case event reference to the blend spinner :

case $.modifiers[#Attribute_Holder].ARM_LEFT_CONTROLS[#Spn_Fk_Ik].value of

Then my question is if I can use your code with the changed value event in this lines to change the text in the button, value 100 = IK value 0 = FK, everything carries me to callback event! the listener says that expect "when" but I have not been able. Thanks

CGTalk Moderation
01-06-2012, 10:11 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.