Link between attribute holder and Control Panel

Hi everybody,

I want to make a "custom attribute holder" on my animation controler to change the parameters "Mass" and "Drag" to my spring, in the motion panel.

I made this script and it works, the Mass and Drag are changed in the control panel of my Spring, when I move my spinner from my attribute holder.
BUT :
When I click on an other controler and return on this one, the spinner doesn't correspond to the right value in the control panel, but of the default value of my spinner.
Solution should be to check the right value in the control panel and set the current value of my spinner egal, but I have absolutly any idea how to do.

I'm not a programmeur and doing this was enough painful ahah
Could you help me please? (sorry for my english)

"SPRING_Control_Custom_attribute = attributes custom_Attributes
(
rollout SpringControlRollout "Spring Control"
(
spinner spn_Mass "Height" range:[0,2000,500] type:#float
spinner spn_Drag "Height" range:[0,10,2] type:#float

on spn_Mass changed val do $'Point001'.position.controller.setMass val
on spn_Drag changed val do $'Point001'.position.controller.setDrag val
)
)

CustAttributes.add $.modifiers[1] SPRING_Control_Custom_attribute"

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture

 

You need a parameter block to hold the values. While you're at it, you can also add a parameter to hold an instance of the controller so that you don't have to rely on scene name:

SPRING_Control_Custom_attribute = attributes SPRING_Control
(
    parameters params rollout:SpringControlRollout
    (
        mass type:#float default:500 ui:spn_Mass
        drag type:#float default:2 ui:spn_Drag
        ctrl type:#maxObject
 
        on mass set val do if isKindOf ctrl SpringPositionController do ctrl.setMass val
        on drag set val do if isKindOf ctrl SpringPositionController do ctrl.setDrag val
    )
 
    rollout SpringControlRollout "Spring Control"
    (
        spinner spn_Mass "Mass" range:[0,2000,500] type:#float
        spinner spn_Drag "Drag" range:[0,10,2] type:#float
    )
)
custAttributes.add $.modifiers[1] SPRING_Control_Custom_attribute
$.modifiers[1].SPRING_Control.ctrl = $'Point001'.position.controller

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.