Digital Art Zone

 
     
Persisting dynamically/programatically added properties?
Posted: 15 December 2012 09:01 PM   [ Ignore ]
Member
Rank
Total Posts:  47
Joined  2010-09-22

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
 

Profile
 
 
Posted: 17 December 2012 10:42 AM   [ Ignore ]   [ # 1 ]
Member
Rank
Total Posts:  89
Joined  2010-12-31
shoei321 - 15 December 2012 09:01 PM

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
 

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

// create a property and add it to the scene
 
m_property = new DzFloatProperty("MyCustomFloat"truefalse0);
 
m_property->setLabel("Custom Float");
 
m_property->setPath("General/Custom");
 
m_property->setIsMappable(true);

 
addProperty(m_property); 
Profile
 
 
Posted: 17 December 2012 11:08 AM   [ Ignore ]   [ # 2 ]
Member
Rank
Total Posts:  47
Joined  2010-09-22

Hmm still not working for me.  Here’s what I’m doing :

DzBoolProperty *onOffProp = new DzBoolProperty(onOffPropNamefalsefalsefalse);
onOffProp->setLabel("On/Off");
onOffProp->setPath(somePath);
onOffProp->setIsMappable(true);
node->addProperty(onOffProp ); 

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?

 

 

 

Profile
 
 
Posted: 17 December 2012 11:20 AM   [ Ignore ]   [ # 3 ]
Member
Rank
Total Posts:  89
Joined  2010-12-31

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

var node Scene.getPrimarySelection()
var 
prop = new DzFloatProperty("MyCustomFloat"truetrue0)
prop.setLabel("Cool")
prop.setPath("General/Custom")
node.addProperty(prop

- save
- load

 

Profile
 
 
Posted: 25 January 2013 06:23 PM   [ Ignore ]   [ # 4 ]
New Member
Avatar
Total Posts:  11
Joined  2010-12-25

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 wink

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…

Profile
 
 
Posted: 04 May 2013 08:00 PM   [ Ignore ]   [ # 5 ]
Member
Rank
Total Posts:  47
Joined  2010-09-22

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?

Profile