Search code examples
3dsmaxmaxscript

Maxscript - Changing the value for all Box objects in a Scene, on different Keyframes?


I am new to Maxcscript, I try to explain a problem the best I can,

I am trying to make a script in Maxscript, that would change a height to a zero of all box objects in a scene on their first keyframe.

I have several scenes that all have a number of boxes, some have 12, some 20 boxes, etc. And all boxes are animated - but on different keyframes, for example first box is animated from 12-23rd frame, second box is animated from 30-45 frame, etc. (so I cant put specific frame number in a script) Right now I am using this script to change a height of a box:

set animate on
modPanel.setCurrentObject $.baseObject
$.height = 0

using this script I have to manualy go to every boxs first keyframe and then execute the script. So, Is there a way in Maxscript to make a script that would go to every box in a scene - go to their first keyframe, turn animate and change its height to a zero; from first to last box in a scene?


Solution

  • I am a beginner too.
    but try this?

    actionMan.executeAction 0 "40021"  -- Selection: Select All
    
    for i in $ do
    (
        if matchpattern i.name pattern: "*Box*" == true do --ObjectName matching part
        (
            local foo = i.height.track  --set Your Animation Controller
            slidertime = getkeytime foo 1
    
            set animate on
            i.height = 0
            set animate off
        )
    )