Modify all the mofifiers of a figure using a single method.

Hello,

I want to write a script which allows to modify morphs on a character.

When I import a character and I open the Parameters Tab, there are a lot of modifiers.
I would like to modify these modifiers using their names.

I made some tests and I found a solution.
Here is a small program which allows to modify the "Nipples" morph.
The current program only displays the Label and the value of this modifier.

fig = Scene.getPrimarySelection();
object = fig.getObject();
numMods = object.getNumModifiers();
print(numMods);
for (i = 0 ; i < numMods ; i++)
{
  curMod = object.getModifier(i);
  if (curMod.getName() == "PBMNipples")
  {
    curProp = curMod.getProperty(0);
    print(curProp.getLabel());    
    print(curProp.getValue());         
  }
}

I made another test to modify the left breast in UP/DOWN direction.
The name of this modifier in the Parameters Tab is "pCTRLlBreastUp-Down".
The corresponding script is:

fig = Scene.getPrimarySelection();
object = fig.getObject();
numMods = object.getNumModifiers();
print(numMods);
for (i = 0 ; i < numMods ; i++)
{
  curMod = object.getModifier(i);
  if (curMod.getName() == "pCTRLlBreastUp-Down")
  {
    curProp = curMod.getProperty(0);
    print(curProp.getLabel());    
    print(curProp.getValue());         
  }
}

This script don't display anything.
The "pCTRLlBreastUp-Down" modifier don't exist by using this method.
This modifier modifies the "lPectoral" node and applies to it a rotation on the X axis.
To modify this modifier, I found this solution:

numNodes = Scene.getNumNodes();
for (i = 0; i < numNodes; i++)
{
  curNode =Scene.getNode(i);
  if (curNode.getName() == "lPectoral")
  {
      print(curNode.getLabel());
      print(curNode.getXRotControl().getValue());
  }
}

This script works fine. My problem is that I will need to modify these 2 morphs using 2 different methods.

My question is:

Is there a method to modify all the modifiers of a figure viewable in the Parameters Tab by using only one method.

I thank you very much for your replies.

 

Comments

  • contessgcontessg Posts: 55

    Please read Modifiers instead of Mofifiers.

    Sorry!!

  • CGI3DMCGI3DM Posts: 276
    oHelper = DzSceneHelper ()oNode = Scene.getPrimarySelection();oProperty = oHelper.findControlProperty("PBMNipples",oNode,1)oProperty.getLabel()oProperty = oHelper.findControlProperty("pCTRLlBreastUp-Down",oNode,1)oProperty.getLabel()

     

  • Controllers, generally those starting CTRL in the Daz products, will not be object modifiers - they will be proeprties of the figure node that drive modifiers (in this case, joint modifiers for the pectorial bones). Have a look at http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start

  • contessgcontessg Posts: 55

    @CGI3DM : Thank you for your reply, this method works perfectly. Thanks again.

    @Richard Haseltine : Thank you for your help. May I ask you 2 small questions.

       - When developping, the "Autocomplete" function would be very helpful. Is there a possibility of having it in the scripting interface?

       - Sometimes I need to write a scripting function without any Internet access. Is there a PDF version of the 4.x Reference Guide? I only found a very old version.

  • contessg said:

    @CGI3DM : Thank you for your reply, this method works perfectly. Thanks again.

    @Richard Haseltine : Thank you for your help. May I ask you 2 small questions.

       - When developping, the "Autocomplete" function would be very helpful. Is there a possibility of having it in the scripting interface?

    That was a feature of the older version of the Qt framework and QSA, sadly not supported in the currently used version of the framework. I don't know if it's present in later versions, if DS moves to one of those.

    contessg said:

       - Sometimes I need to write a scripting function without any Internet access. Is there a PDF version of the 4.x Reference Guide? I only found a very old version.

    No, though you can export the pages of the Wiki as PDF.

  • contessgcontessg Posts: 55

    @Richard Haseltine : Thank you for your replies. You are right, I will export the Wiki in a PDF file.

    @CGI3DM : After another try, I have an issue with the function.

    Here is a function which allows to access to a property using 2 different methods. I hope all the properties will be accessible with this method.

    This function modifies the value of this morph to zero.

    nomMorph = "LGlute Move UpDown 2";
    curHelper = DzSceneHelper();
    curNode = Scene.getPrimarySelection();
    curObject = curNode.getObject();
    numMods = curObject.getNumModifiers();

    propTop = curHelper.findControlProperty(nomMorph,curNode,1);
    if (propTop)
    {
      propTop.setValue(0);
    }
    else
    {
      for (i = 0 ; i < numMods ; i++)
      {
        curMod = curObject.getModifier(i);
        if (curMod.getName() == nomMorph)
        {
          propTop = curObject.getModifier(i).getProperty(0);
          if (propTop)
          {
            propTop.setValue(0);
          }
        }
      }
    }

  • You should check to see if curNode inherits dzBone, and if it does get the matching skeleton since that will have the object.

  • contessgcontessg Posts: 55

    Hello,

    Thank you for your reply.

    I have to look precisely to the DazScript's Object structure.

    In my function, curNode is always a character. I suppose it inherits dzBone. I have to understand the hierarchy.

    Thank you for your help.

  • Characters inherit, but in DS 4 never are, DzSkeleton, their exact type depends on theuir rigging. Bones belong to a figure.

  • contessgcontessg Posts: 55

    Hello,

    Here is an example which I really don't understand despit many tests.

    Here are two morphs on Genesis8. These two morphs are close in the Parameters list but the first one is accessible by the second method, the second is not.

    In both cases, I try to access to these morphs using two different methods. For the first morph, it is the second method which modify the value. You can do some tries.

    I don't if someone can help me to write a method allowing me to access to these two morphs in the same function.

    curHelper = DzSceneHelper();curNode = Scene.getPrimarySelection();curObject = curNode.getObject();numMods = curObject.getNumModifiers();propTop = curHelper.findControlProperty("LGlute Move UpDown 2",curNode,1);if (propTop){  print("1");  propTop.setValue(0);}else{  for (i = 0 ; i &lt; numMods ; i++)  {    curMod = curObject.getModifier(i);    if (curMod.getName() == "LGlute Move UpDown 2")    {      propTop = curObject.getModifier(i).getProperty(0);      if (propTop)      {          print("2");        propTop.setValue(0);      }    }  }}propTop = curHelper.findControlProperty("LGlute Move UpDown 1",curNode,1);if (propTop){  print("1");  propTop.setValue(0);}else{  for (i = 0 ; i &lt; numMods ; i++)  {    curMod = curObject.getModifier(i);    if (curMod.getName() == "LGlute Move UpDown 1")    {      propTop = curObject.getModifier(i).getProperty(0);      if (propTop)      {          print("2");        propTop.setValue(0);      }    }  }}

     

    I thank you a lot for your replies.

  • It depends on whether the property is a cotnroller, for bones or other morphs, or is itself a morph.

  • contessgcontessg Posts: 55

    Thank you for your reply, Richard.

    I made many tests to find a solution to this issue.

    What you said confirms my thoughts, I supposed these properties were not the same ones.

    For the example I sent to the forum, there are two "Parameters" : LGlute Move UpDown 1 and LGlute Move UpDown 2.

    Can you give me a method which allows to modify the values of these modifiers by script?

    I am sure this information will be interesting to many people.

          Gérald

     

  • If you don't know ahead of time which type of property you will be dealing with you may need to try both methods.

  • contessgcontessg Posts: 55

    Hello,

    my explanations was not clear enough.

    I tried a lot of modifiers.

    Some of them are accessible using the first method, other ones are accessible using the second method.

    My current problem is that some of them are not accessible at all. "LGlute Move UpDown 1" is one of them.

    I really don't know how to manage this modifier by script.

    I can find a third method which will allow me to read/write this property but I will never be sure to access to all the properties visible in the "Parameters" tab.

    My question is : Is there a method to access to all the modifiers of this tab?
    A method close to the one used by Daz Studio to display all the parameters of a figure.

    Thanks again to your time.

  • CGI3DMCGI3DM Posts: 276

     

    contessg said:

    Hello,

    my explanations was not clear enough.

    I tried a lot of modifiers.

    Some of them are accessible using the first method, other ones are accessible using the second method.

    My current problem is that some of them are not accessible at all. "LGlute Move UpDown 1" is one of them.

    I really don't know how to manage this modifier by script.

    I can find a third method which will allow me to read/write this property but I will never be sure to access to all the properties visible in the "Parameters" tab.

    My question is : Is there a method to access to all the modifiers of this tab?
    A method close to the one used by Daz Studio to display all the parameters of a figure.

    Thanks again to your time.

    There is a fourth parameter, it may be because of that. nameLabelMatch 

    DzProperty : findControlPropertyString propertyName, DzNode node, Boolean recurse, Boolean nameLabelMatch=false )

    Parameter(s):

    • propertyName - The name of the property to find the control property for.

    • node - The node to find propertyName on.

    • recurse - If node is a DzSkeleton and propertyName cannot be found using findPropertyInGroup(), determines whether to attempt locating propertyName on one of the DzBone owned by the skeleton.

    • nameLabelMatch - Whether the name and label of the property must match propertyName.

  • contessgcontessg Posts: 55

    @CGI3DM : Thanks a lot for your reply, when I set the fourth parameter to true, I am able to read and modify all the modifiers.

    Now, all is perfect, Thank you again.

    @Richard Haseltine : I will make some tests with this function. It is certainly faster than the "findControlProperty" function.

    I will tell you quickly the results of my test. Thank you a lot.

  • contessgcontessg Posts: 55

    @Richard Haseltine: Excuse me to reply so late.

    I took time to understand the function.

    This function returns all the properties of a node. Currently, I don't know what method I will use.

    I thank you a lot for your help.

    Have a great day.

         Gérald

Sign In or Register to comment.