Persisting dynamically/programatically added properties?
shoei321
Posts: 113
When I add properties to a DzNode using DzNode::addProperty() they don't get persisted when I save the scene. Do dynamically/programatically added properties just not get saved?
When I subclass DzNode and add properties in the constructor those properties do get persisted when I save the scene. Do I have to subclass DzNode any time I want to save custom properties?
Thanks
Comments
I assume you are telling the system that they are user properties and that makes sense, except that is not what you want. Tell the system is is not a user property. See the third parameter in the constructor below
Hmm still not working for me. Here's what I'm doing :
After executing this code the property gets added to the node in question. After saving and reloading the scene the property is no longer present on the node. I've also tried explicitly calling onOffProp->setIsUserProperty(false) but no difference.
Note that I am calling addProperty from outside the node constructor (and from outside the node class definition altogether). The node in my test case is just a plain DzNode. Do properties have to be added from within the node class definition itself, and/or from the node constructor, in order to be persisted?
Actually I have told you the exact opposite. UserProperty must be true and then it will work. In other words:
- Create a null
- select it
- execute the following script
- save
- load
i may add something to this: properties set as _non_ user properties are still written into the .duf within the element section, but not into the modifiers library. looks more like a bug to me. even if they were meant to be not saved this will cause garbage, if a similar property is added again in a subsequent run.
also it would be nice to have the possibility to add properties that a user can not change (what the meaning of this flag actually is) and still have them saved. since apparently private properties are no longer saved at all (makes them pretty useless imo). if one really needs to keep properties from saving, a new "dontSave" flag would be a clean and also more understandable solution ;)
and another thing btw: the "show hidden" ui checkbox in the surfaces tab works exactly the other way round in 4.5.1.6... (hidden properities are shown by default, and checking "show hidden" actually hides them). this made me think about how to secure a property from possible user interaction by switching the "is user" flag, only to find them no longer getting saved...
For some reason DzNodeProperty and DzNumericNodeProperty don't persist their value when saved.
What I'm doing is this :
1) Creating a DzNode (aka Null object) from the Daz UI
2) Executing a script that adds a DzNodeProperty to that node
3) Set the value of the DzNodeProperty to some other node in the scene
4) Save the scene
When I reload the scene the DzNodeProperty has lost its value. Other DzProperty types save and reload just fine, but not Node-based properties.
Any ideas here?