Persisting dynamically/programatically added properties?

shoei321shoei321 Posts: 59

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

  • dtammdtamm Posts: 120
    edited December 2012

    shoei321 said:
    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", true, false, 0); m_property->setLabel("Custom Float"); m_property->setPath("General/Custom"); m_property->setIsMappable(true); addProperty(m_property);

    Post edited by dtamm on
  • shoei321shoei321 Posts: 59
    edited December 1969

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

    DzBoolProperty *onOffProp = new DzBoolProperty(onOffPropName, false, false, false);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?

  • dtammdtamm Posts: 120
    edited December 1969

    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", true, true, 0)
    prop.setLabel("Cool")
    prop.setPath("General/Custom")
    node.addProperty(prop)
    

    - save
    - load

  • t__3t__3 Posts: 11
    edited January 2013

    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...

    Post edited by t__3 on
  • shoei321shoei321 Posts: 59
    edited May 2013

    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?

    Post edited by shoei321 on
Sign In or Register to comment.
Rocket Fuel