Home Technical Talk

Key all button with maxscript

marcoslem
null
Offline / Send Message
Pinned
marcoslem null
Hi
I want to know how to create a button to key all my modifiers sliders. Here is my script


---------


sphere pos:[0,0,0]



AttribHolder = EmptyModifier()

addmodifier $sphere001 AttribHolder

ca = attributes Kneescale
(
    parameters KneescaleP rollout:KneescaleR
    (
        slideKneeSc type:#float ui:(slideKneeSp,SlideKneeSl)
        footRoll type:#float ui:footRollSlider
        toes type:#float ui:toeRollSlider
        Knee type:#float ui:kneeRollSlider
    )
   
    rollout KneescaleR "Knee Scale Control"
    (
        local range=[0,100,0]
       
        Group "Foot Control"
        (
            spinner footRollSlider "Foot roll" range:range
            spinner toeRollSlider "toe roll" range:range
            spinner kneeRollSlider "Knee roll" range:range
        )
       
        Group "Scale Knee"
        (
        spinner slideKneeSp    "" range:[0,100,0]
        slider SlideKneeSl "Slide" range:[0,100,0] offset: [0,-20]
        )
       
            Group "Key Animation"
        (
            button keyall "Key All"
            button resetall "Reset All"
        )
       
        on keyall pressed do
        (
                    select $sphere001   
            addnewkey $.modifiers[#Attribute_Holder].Kneescale.footRoll
        )
       
        on resetall pressed do
        (
            slideKneeSc = 0
            footRoll = 0
            toes = 0
            Knee = 0
           
        )
       
       
    )
)
    custAttributes.add $sphere001.modifiers[1] ca


-----

Thank you so much

Marcos Meneghetti





Replies

  • monster
    Offline / Send Message
    monster polycounter
    You don't need to do all that work. Just add the presets attribute after your attribute.
    delete objects
    sphere pos:[0,0,0]
    
    
    
    AttribHolder = EmptyModifier()
    
    addmodifier $sphere001 AttribHolder 
    
    ca = attributes Kneescale
    (
        parameters KneescaleP rollout:KneescaleR
        (
            slideKneeSc type:#float ui:(slideKneeSp,SlideKneeSl)
            footRoll type:#float ui:footRollSlider
            toes type:#float ui:toeRollSlider
            Knee type:#float ui:kneeRollSlider
        )
        
        rollout KneescaleR "Knee Scale Control"
        (
            local range=[0,100,0]
            
            Group "Foot Control"
            (
                spinner footRollSlider "Foot roll" range:range
                spinner toeRollSlider "toe roll" range:range
                spinner kneeRollSlider "Knee roll" range:range
            )
            
            Group "Scale Knee"
            (
    			spinner slideKneeSp "" range:[0,100,0]
    			slider SlideKneeSl "Slide" range:[0,100,0] offset: [0,-20]
            )
        )
    )
    
    custAttributes.add $sphere001.modifiers[1] ca
    custAttributes.add $sphere001.modifiers[1] CustomAttributesPresets


  • monster
    Offline / Send Message
    monster polycounter
    Uh, but if you want to do it the hard way.  >:)
    Notice you have to define an animation controller for the sliders, and use sliderTime for the addnewkey function.

    delete objects
    sphere pos:[0,0,0]
    
    
    
    AttribHolder = EmptyModifier()
    
    addmodifier $sphere001 AttribHolder 
    
    ca = attributes Kneescale
    (
        parameters KneescaleP rollout:KneescaleR
        (
            slideKneeSc type:#float ui:(slideKneeSp,SlideKneeSl)
            footRoll type:#float ui:footRollSlider
            toes type:#float ui:toeRollSlider
            Knee type:#float ui:kneeRollSlider
        )
        
        rollout KneescaleR "Knee Scale Control"
        (
            local range=[0,100,0]
            
            Group "Foot Control"
            (
                spinner footRollSlider "Foot roll" range:range controller:(bezier_float())
                spinner toeRollSlider "toe roll" range:range controller:(bezier_float())
                spinner kneeRollSlider "Knee roll" range:range controller:(bezier_float())
            )
            
            Group "Scale Knee"
            (
            spinner slideKneeSp    "" range:[0,100,0] controller:(bezier_float())
            slider SlideKneeSl "Slide" range:[0,100,0] offset: [0,-20]
            )
            
                Group "Key Animation"
            (
                button keyall "Key All"
                button resetall "Reset All"
            )
            
            on keyall pressed do
            (
    			for con in #(footRollSlider, toeRollSlider, kneeRollSlider, slideKneeSp) do
    				addnewkey con.controller slidertime
            )
            
            on resetall pressed do
            (
    			for con in #(footRollSlider, toeRollSlider, kneeRollSlider, slideKneeSp) do
    				con.value = 0
            )
            
            
        )
    )
    
     custAttributes.add $sphere001.modifiers[1] ca

  • marcoslem
    Hi, Juan

    thank you so much for answer my question. As I work on 3DS Max 2016, it doesn't have custom attributes presets with key all button and reset button. That's the reason I have created this 2 buttons.

    The reset button creates a key on the time slider and works very well. But when I click over key all button, the controllers became red, but there is no key on the time slider. How I create a key when I click the key all button?

    thank you so much

    Marcos Meneghetti


  • marcoslem
    I have found the solution for key all button. Here is:

    ----------
        delete objects
        sphere pos:[0,0,0]
        AttribHolder = EmptyModifier()
        addmodifier $sphere001 AttribHolder
        ca = attributes Kneescale
        (
            parameters KneescaleP rollout:KneescaleR
            (
                slideKneeSc type:#float ui:(slideKneeSp,SlideKneeSl)
                footRoll type:#float ui:footRollSlider
                toes type:#float ui:toeRollSlider
                Knee type:#float ui:kneeRollSlider
            )
           
            rollout KneescaleR "Knee Scale Control"
            (
                local range=[0,100,0]
               
                Group "Foot Control"
                (
                    spinner footRollSlider "Foot roll" range:range controller:(bezier_float())
                    spinner toeRollSlider "toe roll" range:range controller:(bezier_float())
                    spinner kneeRollSlider "Knee roll" range:range controller:(bezier_float())
                )
               
                Group "Scale Knee"
                (
                spinner slideKneeSp    "" range:[0,100,0] controller:(bezier_float())
                slider SlideKneeSl "Slide" range:[0,100,0] offset: [0,-20]
                )
               
                    Group "Key Animation"
                (
                    button keyall "Key All"
                    button resetall "Reset All"
                )
               
                on keyall pressed do
                (
                    for con in #(footRollSlider) do
                         con.value = footRollSlider.value
                   
                    for con in #( toeRollSlider) do
                         con.value = toeRollSlider.value
                   
                    for con in #(kneeRollSlider) do
                         con.value = kneeRollSlider.value
                   
                    for con in #(slideKneeSp) do
                         con.value = slideKneeSp.value
                               
                   
                     )
               
                on resetall pressed do
                (
                    for con in #(footRollSlider, toeRollSlider, kneeRollSlider, slideKneeSp) do
                        con.value = 0
                )
               
               
            )
        )
         custAttributes.add $sphere001.modifiers[1] ca
    ------------

    Otherwise, the key button doesn't create key animation.

    Thank you for your help

    Marcos
Sign In or Register to comment.