local array for rolout?


#1

I want to make a rolout with 2 buttons, the first for loading animation frames and the second to aply them to some scene object(s). How to load frames is no problem and if the frames are stored in an array also no problem to aply them. The problem is with the array, which should be conected to the rolout and when the rolout is deleted (closed) the array should be deleted to.


#2

My suggestion is storing animation values in an xml file. That way you can even copy paste animations between different Max windows.


#3

I personaly would really like to avoid using any IO, specially XML files, since if I got it right .net is necesary for worcking with XML and I dont want to use it.
In some code I´ve seen on the net there were arrays defined as locale inside a rolout, is that posibly a solution?


#4

By the way do you want to keep the array or delete it?
I don’t think it wil keep local variables afer you close the rollout. Try to declare your array before your rollout decleration but! : As soon as you re-run your script your initial array decleration will take over and delete anything stored in the array. So you should check if “yourAnimArray==undefined” before declaring the animation array and then declare your array.
Keep in mind any array values stored in the memory will be erased if max session is ended.


#5

The array should exist only as long the rolout exists, once the roloutfloater is closed, the memory used by the array should be freed.


#6

free your array like
yourArray=#()
with
on <rollout_or_utility> close do <expr>


#7

I have already tried that on <rollout_or_utility> close do , but have problems because not really understanding what that <rollout_or_utility> should be.


#8

My msitake, should have been more clear…
that <rollout _or_uıtility> is the name of your rollout.
your code should be something like

try (DestroyDialog myRollout) catch()
Rollout myRollout "MyRollout" width:100 height:100
(
on myRollout close do( messageBox "opss")
)

createDialog myRollout

#9

Thanks.


#10

The problem is with the array, which should be conected to the rolout and when the rolout is deleted (closed) the array should be deleted to.

my questions are -
why do you think the local array has to be deleted?
what’s the reason?
do you care about memory use?


#11

what you do doesn’t make sense for me.

I believe that some data storage can take a memory. Sure. Of course.
But… you’ve been fine when the rollout was opened, and you didn’t not care… but you begin to worry about memory usage after closing the rollout. Where is the sense?


#12

I am new to maxscript and posibly undderstanding some things wrong, but memory use is something I care about, since the array could be some MBs large and I have not realy an actual PC so memory use counts.
P.S. In my very first post I didn´t said, the array is local. Have used only global arrays with rolouts till now.