[Closed] how to Save / load Object info?
I’m writing an animation pose tool (I know this has been do before but…)
What I want to do is save of the postion data for a bunch of objects, then reload the postions to the same objects at a later date.
I know my way around maxscript well enough to write an interface and move objects around (in fact this part is mostly finished) however…
Is there a way to indentify an object that doesn’t use its name?
Say the user has a rig which has 2 objects with the same name. When I load up the position data for the rig how do I tell which object is which.
Is there a way of getting a unique ID for each object,or will have to create one in some way?
thanks
You could use the AppData interface in Maxscript. It is a way to assign arbitrary data to any node. You could even use it to store some defaults for your control system, etc… Here are some example functions:
fn bAddCustomData oNode nDataID strData =
(
if (oNode == undefined) return false
setAppData oNode nDataID strData
return true
)
fn strGetCustomData oNode nDataID =
(
if (oNode == undefined) do return undefined
return getAppData oNode nDataID
)
So when you first run your tool, you could check to see if data exists on a particular node, if not assign a unique identifier to it and any data you might need for your tool. This data is saved with the scene file.
This is just off the top of my head, there are other ways you could probably do what you need, but this comes to mind first.
Good luck,
Todd Kuehnl
Rapid-TD
I’m all for the appdata method, this is how I have set it up as well in some cases. You can get a unique identifier for all objects in the scene however this will change depending on the order the objects have been added to the scene so it isn’t a good solution. Another good way to store data in an object so that you can later identify it is to use a custom attribute def and store data in it that you can query it later.
ca=attributes mydef
(
parameters paramsP
(
str type:#string
)
)
custAttributes.add $theObj ca
$theObj.str="This is the string that I'm storing"
I don’t have max open but all this looks right.
The difference of using the CA def instead of using appdata is appdata will be deleted if you copy an object. By the sounds of it this is what you want as you don’t want to end up with duplicates.
Thanks for the advice.
I think I will try something simple first. Maybe using the User Properties, and allowing the user to import data to visible objects only.
The main problem we will have is when an animator is using two identically named rigs in the same scene (i.e. two game characters fighting etc). I guess this might be more of an interface design problem than a scripting problem.
I post a link to the script when it’s finished.
thanks
p.s. Pen your ogre rocks :buttrock: