View Full Version : Global custom attributes definitions PROBLEM!
I'm trying to create a tool in order to 'tag' objects with custom informations, and chose to use custom attributes, since it seems to be the most complete method in MXS to record informations in any object...
So I made a 'global' custattribute definition, with an attribID propertie to ensure its "uniqueness", and started to "tag" several objects with it, and found that redefining the custattribute global def with new parameters was automatically updating its instances: cool!
now my problem is that when I import objects with an older definition it replaces the newer one...
so first it's not what it is told in help files:
Global and Private Custom Attributes Definitions
[...] Whenever you evaluate an attributes definition with a particular attribID: you will update all objects that have custom attributes based on that definition, and loading objects with attributes of that attribID will update themselves to the current definition
So I may not have understood something but anyway...
...I tried to use the 'version' propertie of 'scripted plug-ins' in my custom attribute definition, but that doesn't seem to work, and CA instances on the objects I load in my scene keep replacing the ones that are already in the scene, whatever their version number is...
The "Current" definition is the one being merged into the file as it thinks that is the newest. Would be nice if it would use a version system and take the highest version number but I believe it will not take this into account. Change the ID of the new version and implement your own update system for the older version.
I think I'll have to go this way... I'm also a bit dubious about 'version' propertie, but still you can find in help files under Scripted Custom Attributes that it uses the same construction method than scripted plugins and the syntax definition is:
attributes <name> [version:n] [silentErrors:t/f] [initialRollupState:0xnnnnn]
but nothing about version after that...
So I guess I'll have to clean up my objects from their old attributes and put some newer ones with a few more script lines!
I would create your own version parameter and use that to test if it is up to date.
12-22-2010, 05:48 PM
I'm glad someone else thinks this behavior is odd. The definition that's currently resident in memory should always be considered the newest. Assuming the newest definition is the one being brought in from some random file is rather counter-intuitive.
A simple rationalization: Custom Attributes are typically accessed by scripts which are also resident in memory. It seems obvious that the Custom Attribute definition should stay in sync with the scripts which are using it, so the definition in memory should be considered authoritative.
Instead, the definition loaded from a file can undermine what the scripts are expecting. This is a pretty serious oversight in my opinion.
At the very least, the version parameter on Custom Attribute defs should be honored, or some parameter should exist to specify what happens when loading a definition.
I can't even count the number of times I've been bitten by this gotcha.
12-22-2010, 05:48 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.