Map Transfer called from Script

DraagonStormDraagonStorm Posts: 748

Title kinda says my question :)

It there a way to call the Map Transfer interface from within DAZ Script?

And maybe even pass parameters to it?

Post edited by DraagonStorm on

Comments

  • rbtwhizrbtwhiz Posts: 2,184
    edited December 1969

    Launching the "Map Transfer" dialog is fairly simple... provided you know the name of the action that causes said dialog to be displayed.

    var oActionMgr = MainWindow.getActionMgr();
    var oAction = oActionMgr.findAction( "DzTextureConvertorAction" );
    if( oAction ){
     oAction.trigger();
    }

    Note: Originally the tool was named "Texture Convertor" [and still is in the API]; marketing types at the time decided that they didn't like the name that the developers gave it, and requested a change - this only occurred in labels, as we did not want to break source/binary compatibility.

    This tool was previously provided only as part of a "paid" product; it shipped with the application and was unlocked with a serial number. Its API was specifically not exposed to script; you can get to it if you know how [its undocumented/unsupported], but there is nothing of real use. A number of things have changed since that time. If you are interested in accessing the Texture Convertor via script, I would suggest submitting a feature request for specifically exposing it to script.

    -Rob

  • DraagonStormDraagonStorm Posts: 748
    edited December 1969

    rbtwhiz said:
    Launching the "Map Transfer" dialog is fairly simple... provided you know the name of the action that causes said dialog to be displayed.
    var oActionMgr = MainWindow.getActionMgr();
    var oAction = oActionMgr.findAction( "DzTextureConvertorAction" );
    if( oAction ){
     oAction.trigger();
    }

    Note: Originally the tool was named "Texture Convertor" [and still is in the API]; marketing types at the time decided that they didn't like the name that the developers gave it, and requested a change - this only occurred in labels, as we did not want to break source/binary compatibility.

    This tool was previously provided only as part of a "paid" product; it shipped with the application and was unlocked with a serial number. Its API was specifically not exposed to script; you can get to it if you know how [its undocumented/unsupported], but there is nothing of real use. A number of things have changed since that time. If you are interested in accessing the Texture Convertor via script, I would suggest submitting a feature request for specifically exposing it to script.

    -Rob

    There is always that provision isn't there :)... Thank you Rob

  • rbtwhizrbtwhiz Posts: 2,184
    edited December 1969

    Refer to the Find Action Classname sample, when you want to discover the classname of an action... using the label displayed within the UI.

    -Rob

  • DraagonStormDraagonStorm Posts: 748
    edited September 2014

    Rob, I have a question about the Map Transfer Save and Load.. Not sure if you can help or if I need to open a ticket.

    When I save a setup, it doesn't save the Hardware Cut Off and Downsize to Cut Off values to the .dsx files. Are these unavailable? If they are available what are the values for the .dsx (xml)

    Oh, and the class action stuff worked like a charm! Thank you.

    Post edited by DraagonStorm on
  • rbtwhizrbtwhiz Posts: 2,184
    edited September 2014

    Apologies for the slow response... I've been "a little busy". ;)

    Those values do not appear to save/load.

    However, in the spirit of “discovery”...

    // Let's see which managers we can get to from App...
    for( var sMember in App ){
     var sType = typeof App[sMember];
     if( sType == "function" && sMember.endsWith( "Mgr()" ) ){
      print( String("App.%1").arg( sMember ) );
     }
    }
    
    // This one looks interesting...
    var oTexConvMgr = App.getTextureConvertorMgr();
    // Check whether we can get to it from script
    if( oTexConvMgr ){
     print( "-----" );
     
     // Looks like we can, let's see what we can access...
     for( var sMember in oTexConvMgr ){
      var sType = typeof oTexConvMgr[sMember];
      print( sType, String("oTexConvMgr.%1").arg( sMember ) );
     }
     
     // Hmmm, this one could be useful...
     var oTexConvOptions = oTexConvMgr.getTextureConvertorOptions();
     // Check whether we actually have script access to it
     if( oTexConvOptions ){
      print( "-----" );
      
      // Appears so, let's see what we've got...
      for( var sMember in oTexConvOptions ){
       var sType = typeof oTexConvOptions[sMember];
       print( sType, String("oTexConvOptions.%1").arg( sMember ) );
      }
      
      print( "-----" );
      
      // Aha!
      var nHardwareCutOffSize = oTexConvOptions.hardwareCutOffSize;
      var bForceResize = oTexConvOptions.forceResize;
      print( nHardwareCutOffSize, bForceResize );
      
      // Can I set them?
      oTexConvOptions.hardwareCutOffSize = 512;
      nHardwareCutOffSize = oTexConvOptions.hardwareCutOffSize;
      
      oTexConvOptions.forceResize = true;
      bForceResize = oTexConvOptions.forceResize;
      
      // Yep!
      print( nHardwareCutOffSize, bForceResize );
      
      // Ok, so how do I cause the tweaked options to be used?
      // Does DzTextureConvertorOptions inherit DzRenderOptions?
      
      // Yep...
      print( oTexConvOptions.inherits( "DzRenderOptions" ) );
      
      // I recall seeing something about an active renderer... Renderers use options...
      var oRenderer = oTexConvMgr.getActiveRenderer();
      // Check whether we actually have script access to it
      if( oRenderer ){
       print( "-----" );
       
       // Yep, let's see what we've got...
       for( var sMember in oRenderer ){
        var sType = typeof oRenderer[sMember];
        print( sType, String("oRenderer.%1").arg( sMember ) );
       }
       
       print( "-----" );
       
       // Hmmm...
       //oRenderer.customRender( DzRenderHandler, DzCamera, [DzLight]+, [DzNode]+, DzRenderOptions )
       //oRenderer.textureConvert( DzRenderHandler, DzCamera, DzTextureConvertorOptions )
       
       // ...
      }
     }
    }

    No documentation or source code was used to create the script above - I approached it as if I were in your shoes. Debugging code is left in place and the comments simply capture my thoughts as I coaxed the interpreter into telling me what I wanted to know.

    The non-debug laden version...

    var oTexConvMgr = App.getTextureConvertorMgr();
    if( oTexConvMgr ){
     var oTexConvOptions = oTexConvMgr.getTextureConvertorOptions();
     if( oTexConvOptions ){
      var nHardwareCutOffSize = oTexConvOptions.hardwareCutOffSize;
      var bForceResize = oTexConvOptions.forceResize;
      
      //oTexConvOptions.hardwareCutOffSize = 512;
      //oTexConvOptions.forceResize = true;
      
      var oRenderer = oTexConvMgr.getActiveRenderer();
      if( oRenderer ){
       //oRenderer.customRender( DzRenderHandler, DzCamera, [DzLight], [DzNode], DzRenderOptions )
       //oRenderer.textureConvert( DzRenderHandler, DzCamera, DzTextureConvertorOptions )
        
       // ...
      }
     }
    }

    But again, without more of the API exposed to script... success is questionable; there is a function to perform the conversion that does the heavy lifting, but isn't accessible to script.

    -Rob

    Post edited by rbtwhiz on
  • DraagonStormDraagonStorm Posts: 748
    edited December 1969

    Thank you Rob, I'll see what I can do with this :)

Sign In or Register to comment.