Access to MAXWrapper AppData

The AppData access methods give a simple form of access to the AppData capability in the 3ds max SDK. The AppData mechanism provides a way for plug-ins to attach arbitrary data to any 3ds max object in a scene, such as nodes, materials, modifiers, controllers, etc., that is permanently stored with that object in the 3ds max scene file.

The following methods are used to read and store AppData for a MAXWrapper object:

setAppData <MAXWrapper_object> <integer_ID> <string>

Sets the AppData item of the given ID number on the given 3ds max object to the <string> value. This creates a new item if needed or replaces the string contents if an item of that ID already exists.

getAppData <MAXWrapper_object> <integer_ID>

Returns the AppData item string of the given ID number from the given 3ds max object. Returns the value undefined if the ID'd item is not present.

deleteAppData <MAXWrapper_object> <integer_ID>

Deletes the AppData item if the given ID number from the given 3ds max object.

clearAllAppData <MAXWrapper_object>

Clears out all MAXScript-related AppData items from the given MAXWrapper object.

You can add as many AppData strings as you like to an objectùyou assign them each an integer identification number when they are first added and access them later using those IDs.

AppData strings can be attached to any MAXWrapper subclass instance, including scene nodes, modifiers, controllers, materials, atmospherics, etc. Note that the AppData is stored in the scene file only if its object is in the sceneùif, for example, you create a material in MAXScript and do not assign it to any object or the material editor, it will not be saved in the scene file nor will its AppData.

If you want to associate certain AppData strings with the scene as a whole, it is recommended that you create a hidden dummy node with a unique name and attach the scene AppData to that node.

AppData in its full generality allows the C++ plug-in developer to store arbitrary binary data with an object. This is not directly possible with MAXScript, so the approach taken is to store and retrieve AppData text strings that can be built-up or parsed into complex MAXScript objects using a StringStream Value. For example, to store some numbers in an array on a scene node, you might do the following:

ss = StringStream ""

for v in data_values do print v to:ss

setAppData $foo 1 ss

and read them back after the scene has been saved and reloaded as follows:

ss = StringStream (getAppData $foo 1)

data_values = #()

while not eof ss do

append data_values (readValue ss)