Search code examples
3dsmaxmaxscript

Number range animation with maxscript


i'm new to maxscript and i'm trying to animate (show) numbers from number 0 to number 220 with maxscript. My problem is that i want to make integer range but with this code, it's making float number. help me !

b=box name: "ControlBox" wirecolor:blue height:1
t=text name: "ControlledText" wirecolor:red
t.baseobject.renderable=true
theCtrl = float_script() 
theCtrl.addNode "TheText" t 
theCtrl.addNode "TheBox" b
theCtrl.SetExpression "TheText.text = TheBox.height as string\n0"
t.kerning.controller=theCtrl
animate on at time 100 b.height=220 
max tool zoomextents all
playAnimation()

Solution

  • Change TheBox.height to int(TheBox.height) in your expression. There are also ceil and floor functions if you want to round to the next lower/higher number before truncating.