[Closed] Updating Existing Scripted Custom Attributes
Say I have a lengthy custom attribute on the rootnode that holds a myriad of scene-specific data for a tool. This tool is ever-evolving, and new parameters are added on a semi-regular basis.
Building handler functions to migrate the data is turning into an enormous amount of code to handle all the previous versions of the CA from its inception…
How can I redefine the custom attribute such that all the old exisiting data and the name remain the same, but the new paramater is simply ‘tacked’ onto the end of the exisiting definition?
The help on CA redefine and remap seems to apply to changing the names of existing paramaters to new ones, not simply adding entirely new parameters. Or I am misunderstanding the help altogether.
Thanks in advance for any help!
paul neale’s site has a great tool called PEN rigging utilities that will allow you to redefine your CA defs. I use it all the time and couldn’t live without it.
The basis of that code is simple really. First you need to get an instance of the definition in the scene.
def=custAttribute.getDef $thObject.'attribute holder' theDefName
next get the actual code from that def with and print it to a new script window.
format def.source to:(newScript())
To update the definition you can just add the line redefine to it like this.
attributes theDefName redefine:def
(
parameters...
rollouts...
)
You can also use
custAttributes.redefine def theNewDefinitionString
The last is what I use if I have to update definition using post file open callbacks when people open the file. theNewDefinitionString is the definition that has been read in from a file on the server.