Setting parameters of a figure in script

Hi, I am just starting with a little scripting and just needed some pointers please.

I would like to make a script that programmatically changes the values of the head bend and twist, but don't really know where to start.

See my image, I have V4.2 loaded and those are the dials I want to change,

How would I go about selecting the actor and then changing setting the value of those dials in my script ?

In the meantime I will keep hunting, I found some useful things but am a bit stuck on this bit. atm

Cheers :)

Comments

  • Richard HaseltineRichard Haseltine Posts: 96,718
    edited December 1969

    You need to identify your figure - usually by selecting it and using Sceen.getPrimarySelection() or Scene.getSelectedFigureList(). Then you can use figure.findNodeChild( "name" , true ) to get the ehad and neck. For each of those use node.getXRotControl() and so on to get the parameters. For the controls you then use control.getValue() and control.setValue( val ) to make the changes.

  • Widdershins StudioWiddershins Studio Posts: 539
    edited February 2013

    Great thanks, figured it out thanks to you :)

    Post edited by Widdershins Studio on
  • Widdershins StudioWiddershins Studio Posts: 539
    edited December 1969

    OK, I got that working. Now I have got the head (I'm using V5) I would also like to set the mouth shape.

    So it seems I find the head node again as the Visemes are in the head.

    How do I select, for example; 'IY' and set it's value please ?

    Cheers :)

  • Richard HaseltineRichard Haseltine Posts: 96,718
    edited December 1969

    The head "morphs" atr actually not true morphs, those are on the root node, they are properties. This should work:

    var prop = node.findPropertyByLabel( "IY" );
    if ( prop ) {
     prop.setValue( 1 );
    }
  • Widdershins StudioWiddershins Studio Posts: 539
    edited December 1969

    Thanks Richard that worked a treat :)

  • kitakoredazkitakoredaz Posts: 3,526
    edited May 2014

    (I have only simple java-script knowledge,, so that please forgive me to join this forum,,
    and If modelator think,, there is more good place for "me" to ask about ds scripts basics , and
    plug in with Qt creator, and C++ for daz studio, send me the forum please,,

    Then,,,I want to know clear, how to access each properties (in parameter tab) of each Node,
    and just set value, (get value too) by "property path and name" which can see in parameter tab.

    Now I get Node, like that (to test , just get top node of Nodelist in the scene)

    var nArray = Scene.getNodeList();
    var tNode = nArray[0];
    var tPropTree = tNode.getPropertyGroups();
    var allPropertyPaths = tPropTree.getAllPaths();
    print(allPropertyPaths)

    it can tell me all property Paths ,,(not property name,,)

    I want to find way to get all "Paths and property names" of Node.

    and hope to access and set each proeprty value by using "path and name" or "name" only if I can,,

    eg,, now there is one property ,, Mymorphs/morph1
    how can I achieve it?

    ================
    edit,, ah,,OK I could not find the method to get property of DazNode,,
    DazNode seems have no method to find property,,

    but all DzElements method can use for children too?
    maybe I can use "var tProp = node.findProperty(morph1) "?
    then,, tProp.setValue() ?

    then why Rechard can find setvalue() method,, frome where^^;
    because,, I can not find the method in DzProperty methods,,
    I want to understand more about setValue(),,, where can I find ti,,??

    Post edited by kitakoredaz on
  • Richard HaseltineRichard Haseltine Posts: 96,718
    edited December 1969

    Yes, children inherit (or rewrite) the methods of all their parents. Properties are (usually) DzFloatProperty (use .inherits( "DzFloatProperty" ) to check) and setValue() belongs to that.

  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    Richard Thanks to teach me so many things everytime I asked .. (T T)

  • Widdershins StudioWiddershins Studio Posts: 539
    edited December 2015

    Hi Richard

    Could you please expand a little on the C++ way of doing this. I've tried a few things and can't figure it out for a plugin.

    Thought this might do it, but it doesn't.

     

    while (nodeIt.hasNext()) {DzObject	*obj = nodeIt.next()->getObject();DzProperty *foo = obj->findProperty("XTranslate");foo->setValue(10);}

     

    Also...

     

    while (nodeIt.hasNext()) {		DzObject	*obj = nodeIt.next()->getObject();		obj->property("XTranslate") = 10;		obj->property("YTranslate") = 10;		obj->property("ZTranslate") = 10;	}

     

    Appears to do nothing.

    Can't find anything on Google or here at the moment.

    Cheers :)

    Post edited by Widdershins Studio on
  • Also tried :

    obj->setProperty("XTranslate", 50);

    Nada

  • I've not done any plug-in codong (or any C++ coding at all for about twenty years). But - why are you using the object, assuming the name reflects the data, to look for the properties? The object will have the modifiers, if it's the same as a script, but then you would ahve to get their value channel - getting the scene node and then its value channel, if the plug-in API supports that, would seem more direct.

  • Well I built a working prototype in Daz Script but I need to extend it beyond that.

    I need to iterate through all selected nodes in the scene. In Daz Script the XTranslate etc are in the objects property groups.

    But it's different in C++.

    I've started a new thread in the SDK section for this since it's C++...

    http://www.daz3d.com/forums/discussion/66984/how-to-set-properties

     

  • But in the first code snippet you are setting the properties, which are data types with members, to a numeric value - you would , in scripting, get the property and then use its setValue function as in my snippet from earlier not simple set the value to a number.

  • You mean this bit ?

    obj->property("XTranslate") = 10;

    Yes I think I see what you mean. Sorry I am really new to C++, I'm finding it difficult to pick up compared to other languages.

    I've got as far as this but there is no setValue available.

     

    DzNodeListIterator	nodeIt(dzScene->selectedNodeListIterator());	while (nodeIt.hasNext()) {		DzObject	*obj = nodeIt.next()->getObject();		DzPropertyGroupTree *foo = obj->getPropertyGroups();		DzPropertyGroup *bar = foo->findChild("XTranslate");		// Hmm now what.	}

     

    That's the closest to mirroring Daz Script to C++ that I can find, but as said there is no setValue()...

    Also in Daz Script I used...

    var oPropertyGroups = oObj.getPropertyGroups();oPropertyGroups.findProperty("XTranslate").setValue(100);

     

    So as you can see I am trying to replicate that in C++ and failing miserably !

  • Spent hours on this yesterday, found the solution within half an hour this morning.

    I posted it in the SDK thread I linked above as it's C++.

Sign In or Register to comment.