PDA

View Full Version : Storing information (Arrays in Scene)


EverZen
06-18-2007, 11:16 PM
Hi guys,

I am trying to write some pretty large tools to help with a project pipeline. I really want to be able to store data information in a scene (array data), without the artists accidently deleting it from the scene. But the data needs to be saved/loaded in the scene file.

As I understand it, to actually be able to have data stored into a scene, you have to deal with a plugin (maxscript in my case) of at least Level 3. This is not a problem to create (although I have very little experience with scripted pluggins). But I want this data to sit silently in the background, so that I can access it when I want for specific purposes. The problem is, say I make a plugin with superclass "helper", then I can write out all the lovely parameters that I need. But I then need to create an instance of this helper plugin in the scene. This isnt really a problem, except it appears in the select objects list, and therefore can be accidently deleted etc. I could create it as a texturemap plugin or something, but then there could be the same problem when the artists Texture.

Is there a way to write a plugin that can store some really simple data, and will be saved with the scene, but will not appear in an obvious way that might be deleted. (I want to then access the data from a series of Maxscripts, so ideally the artists wont ever accidently bump into it, and potentiallty delete it.... I have used invisible:true , so it doesnt appear on the create menus, but the instance will still be selected if an artist "selects all" for example.

Any ideas guys? Being able to do this would be so cool for so many of the tools that I am writing at the moment!

Thanks for your time everyone.

EverZen

magicm
06-19-2007, 12:49 AM
I think your best option is create a new track in the GlobalTracks node. Then you can either store your data using custom attributes or by adding a script controller to the new track. These take a few clicks or maxscript to be deleted, so chance of having it accidently deleted is relatively small.


On a side note, I've accidently found a way of hiding an object from the "Select By Name" list some time ago. It's a hack though and I'm not sure if it could cause any stability issues. It's as simple as this:
b = box isHidden:true
setGroupMember b true
Here's some info from the manual:
If you set a node to be a group member using this method,
you need to set the node to be a child of a group head.
Otherwise, the node name is not shown in the Select By Name dialog.
Hope this helps,
Martijn

JohnSwafford
06-19-2007, 01:02 AM
Is there a way to write a plugin that can store some really simple data, and will be saved with the scene, but will not appear in an obvious way that might be deleted.

You don't need to write any plugins for this...check out these discussions:

http://forums.cgsociety.org/showthread.php?t=484595 (AppData storage)
http://forums.cgsociety.org/showthread.php?t=501585 (Persistent Globals)
http://forums.cgsociety.org/showthread.php?t=356144 (Persistent Globals)

I personally would recommend setAppData/getAppData storage on the scene's rootNode for small arrays of integers/floats/strings, and Persistent Global Variables only if you have very large arrays of data. AppData is much simpler and easier to bulletproof than persistents. (You can also use Custom Attributes applied to the rootNode, but I haven't used them and in my opinion they are much harder to learn.)

EverZen
06-19-2007, 12:03 PM
Thanks Martijn and John,

Cheers Martijn - You are right about the global tracks, it is keeps everything nicely away from the user so there is little or no chance that data is going to be removed. The hidden item trick is also great, it is so cool when you discover random events like this. I have played with it, and it seems actually to be a viable option, but I would it might come back to bit me later, and I bet if it did, the cause would almost be impossible to track down.

Thanks John - Was completely unaware that this feature even existed, and I imagine will prove invaluable in certain situations in the future. Those threads lead to some really interesting discussions, and problems that I would have never seen coming if I had stumbled into this blindly. Will definitely have a play with the AppData storage, since I can think of so many scenarios where this will be useful.

Cheers guys, top work, and thanks for your time.

Best wishes,

EverZen

CGTalk Moderation
06-19-2007, 12:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.