Sharing a property between nodes?

I would like to be able to have one instance of a property (DzFloatProperty in this case) be shared between two nodes.       Something like this :

DzFloatProperty* prop = new DzFloatProperty();node1->addProperty(prop);node2->addProperty(prop);

 

The above code runs without error but the property is only listed under the first node.    I believe this is possible in Daz however -- the Twist property appears to be shared between the Bend and Twist nodes in Genesis3 for Thigh/Shoulder/Forearm.  

Any suggestions on how to do this?

Thanks

 

Comments

  • rbtwhizrbtwhiz Posts: 2,250

    DzProperty::createAlias()

    Create a property alias and put that alias on node2. A property alias has its own presentation, but will forward edits of all non-presentation values to the property it is an alias of.

    -Rob

  • shoei321shoei321 Posts: 113
    edited April 2016

    Thanks Rob.   I've gotten that working now, but with one caveat -- If I save and reload the scene, the aliases are all missing.   My code is essentially what you said :

    node->addProperty(prop);DzProperty* alias = prop->createAlias();alias->setName(prop->getName()); // alias->getName() is empty, so I have to manually set itotherNode->addProperty(alias);

     

    The application log shows these messages on scene reload :

    WARNING: fileinput\dzassetdaz.cpp(7365): Could not find reference: NodeName:/Scenes/SceneName.duf#PropName?valueWARNING: fileinput\dzassetdaz.cpp(1401): Failed to create alias!

     

    Do you have a broader example of alias usage you could copy & paste here?

     

    Thanks

     

     

    Post edited by shoei321 on
  • edited April 2016

    This helped also - Thanks Rob

    Post edited by newwork.newwork_94ee83a19e on
  • rbtwhizrbtwhiz Posts: 2,250

    The property and the alias must each have a name. The name for a given property (or property alias—which is really a subclass that forwards edits to the property it is an alias of) must be unique on a given element owner.

    DzProperty* prop = new DzFloatProperty();QString propName = "MyUniquePropertyName";nodeA->isPropertyNameUnique( propName, true );prop->setName( propName );nodeA->addProperty( prop );DzProperty* alias =  prop->createAlias();QString aliasName = prop->getName();nodeB->isPropertyNameUnique( aliasName, true );alias->setName( aliasName );nodeB->addProperty( alias );DzPropertyHelper::setPropertyPath( alias, prop->getPath() );

    -Rob

Sign In or Register to comment.