How to set properties
Widdershins Studio
Posts: 539
I'm having trouble setting properties of a model in the scene.
What I would like to do is learn how to move any selected nodes to a translation x of 100.
I've got this all working in Daz Script, but can't figure out how to do it in C++.
This is what I am trying now, but Daz crashes.
DzNodeListIterator nodeIt(dzScene->selectedNodeListIterator()); while (nodeIt.hasNext()) { DzNode *myNode = nodeIt.next(); DzFloatProperty *myX = myNode->getXPosControl(); myX->setValue(100); }
Thanks for any help.
Comments
Just from a C++ perspective, that looks like an infinite loop (assuming nodeIt.hasNext() is not null).
It's infinite, because nothing in the body changes what nodeIt points to. Maybe try adding in the body of the loop a
nodeIt=nodeIt.next();
...unless of course, that the DzNodeListIterator.next() method automatically updates the object. Not sure how the iterator class is structured in the Daz libraries.
(I'm an old hand at C/C++, but I'm new to DAZ coding....)
The other possible problem is if dzScene->selectedNodeListIterator() returns an empty or null node. Then an attempt to call nodeIt.hasNext() would cause an exception (attempting to dereference a null.) Might want to put in a test to make sure.
I think the NodeIt does the iterations, I'm not getting any errors from the loop itself.
I think the nodetIt.next() moves the pointer. ie this line :
I used it from an example and that's the way it was done.
I'll try it without anything in the loop just to make sure.
Got it...