How do you set the property value slider in the parameters tab

GenerationXGenerationX Posts: 56

How do you read back and set the selected or highlighted property value slider in DAZ3d Studio using C++

I want to highlight a slider and press a key to reset to zero or a value....

Post edited by GenerationX on

Comments

  • rbtwhizrbtwhiz Posts: 1,869
    edited July 2015

    The Parameters pane is not [directly] accessible via the [C++] Plugin SDK. It is, in fact, part of a plugin itself; i.e. Interface Components.

    So, why make a point of indicating "directly" instead of just saying "no"? Well, because it is possible to generate and execute script via plugin (if you are dead set on a plugin being involved)... and the Parameters pane is accessible via script... IF you're up for a bit of self-discovery (i.e. no published documentation) and you realize that what you discover isn't officially supported. Meaning, it may change, without warning or notification.

    Below is an example of what I mean by "self-discovery"...

     

    var oPaneMgr = MainWindow.getPaneMgr();var oPane = oPaneMgr.findPane( "DzParametersPane" );if( oPane ){ var oDefinition; var aMembers = []; for( var sMember in oPane ){  oDefinition = oPane[ sMember ];  switch( typeof( oDefinition ) ){   case "function":    aMembers.push( sMember );    break;   case "object":    if( oDefinition.toString().startsWith("[") ){     aMembers.push( [sMember, "=", oDefinition.className()].join(" ") );    } else {     aMembers.push( [sMember, "=", oDefinition].join(" ") );    }    break;   default:    aMembers.push( [sMember, "=", oDefinition].join(" ") );    break;  } } aMembers.sort(); print( aMembers.join("\n") );}

     

    Of particular interest to you, in this instance, will be a function named "getNodeEditor". Iterating over the members of the return value for this function will reveal a function named "getPropertySelections". So, you may eventually end up with something like...

     

    var oPaneMgr = MainWindow.getPaneMgr();var oPane = oPaneMgr.findPane( "DzParametersPane" );if( oPane ){ var oEditor = oPane.getNodeEditor(); var aProperties = oEditor.getPropertySelections( true ); for( var i = 0; i < aProperties.length; i += 1 ){  print( aProperties[ i ].getLabel() ); }}

     

    This is, of course, just one piece of the puzzle. I can tell you, with absolute certainty, that you can accomplish what you describe... i.e. assign a shortcut to a custom action that executes a script, that utilizes the scripting API to obtain an array of selected properties from the Parameters pane and then modifies those properties in some way. But you're going to have to learn how to fish a little, to get there... (ref. "If you give a man a fish, you feed him for a day. If you teach a man to fish, you feed him for a lifetime.").

    If you are interested in continuing the discussion, being as this will be a scripting endeavor, it would be best to move this thread to the Developer Discussion forum so that those who script might also benefit.

    -Rob

    Post edited by rbtwhiz on
  • GenerationXGenerationX Posts: 56
    edited December 1969

    Thanks for the info, just need to convert to SDK plugin :down:

    var oPaneMgr = MainWindow.getPaneMgr();
    var oPane = oPaneMgr.findPane( "DzParametersPane" );
    if( oPane ){
    var oEditor = oPane.getNodeEditor();
    var aProperties = oEditor.getPropertySelections( true );
    for( var i = 0; i < aProperties.length; i += 1 ){
    print( aProperties[ i ].getLabel() );
    aProperties[ i ].setValue(1.0); //<--= Set the value here<br /> }
    }

  • GenerationXGenerationX Posts: 56
    edited December 1969

    Ok this works in c++, but how do you read back the script value and get the selected node in c++?

    
     //----------------------
     // Get DzParametersPane
     //----------------------
     DzMainWindow *mw = dzApp->getInterface();
     DzPaneMgr *myPaneMgr=mw->getPaneMgr();
     DzPane *myPPane=myPaneMgr->findPane( "DzParametersPane" );
     if(myPPane){
      //------------------
      // Build the script
      //------------------
      float fInput=4.0f; //<---= The test input value
      if(!MyScript)MyScript=new DzScript; //DzScript *MyScript;
      MyScript->clear();
      MyScript->addLine("var oPaneMgr = MainWindow.getPaneMgr();");
      MyScript->addLine("var oPane = oPaneMgr.findPane( \"DzParametersPane\" );");
      MyScript->addLine("if(oPane){");
      MyScript->addLine("var oEditor = oPane.getNodeEditor();");
      MyScript->addLine("var aProperties = oEditor.getPropertySelections( true );");
      MyScript->addLine(QString(" for( var i = 0; i < aProperties.length; i += 1 ){aProperties[ i ].setValue(%1);}").arg(fInput));
      MyScript->addLine("}");
      //------------------
      if(MyScript->execute()==true){dzApp->statusLine( "Script OK",FALSE );}else{dzApp->statusLine( MyScript->errorMessage() ,FALSE );}
      //------------------
     }else{dzApp->statusLine( "PP not Found",FALSE );}
     //----------------------
    
  • cwgantcwgant Posts: 16
    edited December 1969

    So I take it that "The Parameters pane is not [directly] accessible via the [C++] Plugin SDK." applies to the Property Hierarchy pane as well? It's also a plugin or part of one? I could get a pointer to the "DzHierarchyPane" but not be able to read or modify Node properties (Parameter Settings), correct?

    So if Scripting is the answer but most of my functionality must be in a [C++] Plugin, how would one pass data from Plugin to Script and back?

  • GenerationXGenerationX Posts: 56
    edited April 2014

    cwgant said:
    So I take it that "The Parameters pane is not [directly] accessible via the [C++] Plugin SDK." applies to the Property Hierarchy pane as well? It's also a plugin or part of one? I could get a pointer to the "DzHierarchyPane" but not be able to read or modify Node properties (Parameter Settings), correct? <----= YOU CAN PASS DATA FROM SCRIPT TO C++ AND C++ TO SCRIPT....:)</strong>So if Scripting is the answer but most of my functionality must be in a [C++] Plugin, how would one pass data from Plugin to Script and back?


    In your public DzPane class insert:

    public slots:
    slots:
     // GOLBAL PUBLIC SLOTS
     virtual void MyInput(char In); //Function must be public


    In your main .cpp

    void MyClassName::MyInput(char In)
    {
    //what ever here :)
    return;}


    Change the “MY_PANE” to your DzPaneAction name. Use the code at the top of this page to see if your MyInput functions get listed don't forget to change "DzParametersPane" to your DzPaneAction name..

    
    Insert code as one line!!!!
    MyScript->addLine("
    var oPaneMgr=MainWindow.getPaneMgr();
    var oPane=oPaneMgr.findPane(\"MY_PANE\");
    if(oPane){oPane.MyInput('A');}  /*Send to my c++ prog from DzScript */
    else{ /*My pane not found*/ }
    ");

    You can send the node address my changing (char In) to (DzNode* In)
    I have tested this out and is works. :p

    Post edited by GenerationX on
  • GenerationXGenerationX Posts: 56
    edited April 2014

    //-----------------------
    // READ DAZ SCRIPT INPUT
    //-----------------------
    void myClassPane::PoseItScriptInput(int In)
    {
     dzApp->statusLine( QString("Daz script input was: %1").arg(In),FALSE );
    }
    
    //-----------------------
    // CREATE DAZ SCRIPT C++ 
    //-----------------------
    void myClassPane::TestInput()
    {
     DzScript *Script=new DzScript;
     Script->clear();
     Script->addLine("var Send=12345678; /*Send to plugin*/");
     Script->addLine("var oPaneMgr=MainWindow.getPaneMgr(); var myPane=oPaneMgr.findPane(\"TheNameOfActionPane\"); if(myPane){myPane.PoseItScriptInput(Send);}"); /*Change TheNameOfActionPane to your pane name*/
     if(Script->execute()==false){dzApp->statusLine( Script->errorMessage() ,FALSE );}
    }
    
    Post edited by GenerationX on
  • cwgantcwgant Posts: 16
    edited December 1969

    Thank you for the example! I'll give it a try.:-)

  • cwgantcwgant Posts: 16
    edited December 1969

    So I found this script:

    http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start

    Which is very cool at demonstrating how to iterate thru all the properties of a selected node. It got me thinking about an almost abandoned approach to duplicating the same thing in Qt (SDK C++). So I tried... and somewhat succeeded. Looks like I can iterate thru every property (DzProperty) as well as all the available keys associated with that property (DzPropertySettings) fairly well. Once put into an array, I can loop thru and pick out what I want to look at:

    
     DzPropertySettings mySettings;
     int i;
    
     QListIterator propNew(propertyArray);
     while (propNew.hasNext()){
      myProp = propNew.next();
      myLabel = myProp->getLabel();
      if (myLabel == "Y Rotate"){
    
       myProp->getAttributes(&mySettings;);
    
       for (i = 0; i < 20; i++){
        html += QString("Property : %1  :   %2").arg(  mySettings.getKey(i), mySettings.getValue(i) );
       }
    
      }
     }
    

    I picked out a specific property for example "Y Rotate" and looked thru the settings (DzPropertySettings) to see what I can pick up:

    Current selected node is: Genesis
    Property : Label : Y Rotate
    Property : Hidden : no
    Property : Path : /General/Transforms/Rotation
    Property : UserProperty : no
    Property : CanAnimate : yes
    Property : Locked : no
    Property : Manipulator : yes
    Property : Favorite : no
    Property : GlobalFavorite : no
    Property : Selected : no
    Property : AutoFollow : no
    Property : XYZInterest : Y
    Property : Clamped : no
    Property : Mapable : no
    Property : NeedMap : no
    Property : DefaultImageGamma : 1
    Property : Min : 0
    Property : Max : 0
    Property : Sensitivity : 0.5
    Property : AsPercent : no

    I tried other indexes but there are only 20. So what is missing? The actual value of the property. I have no idea how to proceed. In the script example, I added a 4th column on the output section to see if getValue() would work. It does.

    
    // Get the primary selection
    var oNode = Scene.getPrimarySelection();
    // If something is selected
    if( oNode ){
     // Get the properties available to the user by way of the selected node
     var aProperties = getNodeProperties( oNode, true, true );
     // Declare variables we'll be using as we iterate
     var oProperty, oOwner;
     // Iterate over all properties
     for( var i = 0; i < aProperties.length; i += 1 ){
      // Get the "current" property
      oProperty = aProperties[ i ];
      // Get the owner of the property
      oOwner = oProperty.getOwner();
      // If the property is on the node itself
      if( oOwner.inherits( "DzNode" ) ){
       print( String( "%1 : %2 : %3 :     %4" ).arg( oOwner.className() ).arg( oProperty.name ).arg( oProperty.getLabel() ).arg( oProperty.getValue() ) );
      // If the property is not on the node itself
      } else {
       print( String( "%1 : %2 : %3 :     %4" ).arg( oOwner.className() ).arg( oOwner.name ).arg( oProperty.getLabel() ).arg( oProperty.getValue() ) );
      }
     }
    }
    

    As for the Qt (SDK C++) code side of it, I believe DzFloatProperty or DzNumericProperty may be involved. But I have no idea how to get from DzProperty to the Float or Numeric property. Does anyone have any ideas? Rob? Any secret squirrel handshake - don't mind that many behind the curtain... kinda hint?

  • cwgantcwgant Posts: 16
    edited December 1969

    Ah.. never mind... I got it.

    My lack of Qt strikes again. And my C++ isn't all that good either. But... I can now read and write to any property on a selected node... With a SDK C++ plugin. No script. Now the fun starts!

    Here's the missing piece:(see my prev post for the rest of this)

    
    DzFloatProperty *myFloat = qobject_cast(myProp); //cast the selected property into a DzFloatProperty class.
    
    html += QString("Property : %1").arg(myFloat->getValue()); //show the current value
    
    myFloat->setValue(10.1234);  //for example, write directly to the value.
    
  • up4up4 Posts: 8
    edited April 2015

    Hello,

    So I ran the "pane explorer" script found in the above posts on the "aniMate" pane. My goal is to randomly load aniblocks on all the figures in the scene. By looking at some of the files in the animations bundles I purchased on the DAZ store, I saw that they were using the addBlock(QString) method to add an aniblock to a layer. But I first have to create a layer for a given figure before I can call that method. From the "pane explorer" dump, there are two candidate methods I suspect might do the job for me:

    getAnimateTrack(const char*,const char*,bool,void**);
    addValue(QString,QString,QString,float,int,int,int);]

    getAnimateTrack is the main culprit. But I don't know what the parameters are. I suspect the two strings to be the name of the figure node in the scene and the name of the aniMate layer to be created, the bool I will figure out eventually, I guess, but the last function (a return handler?) I don't know. As for the addValue method, I prefer to ask first instead of guessing.

    Anyone using those could help me a little?

    Thanks,

    Vincent

    Post edited by up4 on
  • up4up4 Posts: 8
    edited December 1969

    Reverse engineering is not that easy. ;-)

    If I try this:

    oPane.getAnimateTrack("Genesis 2 Male", "Genesis 2 Male", true, null);

    I get this:

    Executing Script...
    Script Error: Line 5
    TypeError: cannot call getAnimateTrack(): argument 1 has unknown type `const char*' (register the type with qScriptRegisterMetaType())
    Stack Trace: ()@:5
    Error executing script on line: 5
    Script executed in 0 secs 0 msecs.

    I'll put that on hold until I get cheered up by some of you guys! ;-)

    Help is welcome!

    Vincent

  • ammon_fde0d92863ammon_fde0d92863 Posts: 119
    edited December 1969

    up4 said:
    Reverse engineering is not that easy. ;-)

    If I try this:

    oPane.getAnimateTrack("Genesis 2 Male", "Genesis 2 Male", true, null);

    I get this:

    Executing Script...
    Script Error: Line 5
    TypeError: cannot call getAnimateTrack(): argument 1 has unknown type `const char*' (register the type with qScriptRegisterMetaType())
    Stack Trace: ()@:5
    Error executing script on line: 5
    Script executed in 0 secs 0 msecs.

    I'll put that on hold until I get cheered up by some of you guys! ;-)

    Help is welcome!

    Vincent

    I am sorry to inform you that aniMate does not really support what you want to do.

    getAnimateTrack is a leftover function from a past project. The method does nothing.

  • up4up4 Posts: 8
    edited December 1969

    Oh! Sad. Thanks for your reply.

  • GenerationXGenerationX Posts: 56
    edited December 1969

    up4 said:
    Oh! Sad. Thanks for your reply.

    Not sure what your trying to do, but you will find no handy functions in animate2! If there is any c++ plugins ideas let it be said here. :coolsmile:

Sign In or Register to comment.