Total Noob Question: Daz Script calling a Plugin or dll? [SOLVED]

bigD3dbigD3d Posts: 75

Hello everyone,

I have a project I'm doing which I hope to get onto the store at some point. At the moment i'm struggling through some image processing/manipulation where i'm iterating over every pixel in an image (Image.setPixel(x,y,color)).

For small images it can finish relatively quickly like in about 30 seconds to 1 min. But as the image size gets larger I've had it take as long as 10-15 minutes. And this is on my Ryzen 3900X with 64gb of ram. I still have more code to add in to polish it out which may raise this by a factor of 4 and maybe even 16. 

All this has me thinking I need to offload this part of the process and have it be done in C++ as either a plugin or maybe a dll? And then hopefully that plugin or dll can be called from my existing Daz Scripts passing in the needed params?

 

I am not a C++ coder and never done anything with DLLs - which is why I started doing this project in Daz Script in the first place.But if there's no way to increase the processing speed, then I may be forced to anyway.

Assuming for arguments sake there is a way to do this, would I use DzProcess() to make the call to that plugin/dll, or is there another way I haven't seen yet?

Thanks for any light anyone can shed on this.

 

Post edited by bigD3d on

Comments

  • A plug-in is a .dll. You could write the difficult bit as an external application (.exe) and then use DzProcess() to launch it with a command line, for a plug-in you don't call anything in that sense - the plug-in has to be written to make certain functions and objects publicly available and then a script can call those (that is how Figure metrics can use the Measure Metrics plug-in).

  • bigD3dbigD3d Posts: 75

    Thanks Richard,

    so if I understand you right I have these two options?

    1) make my code into an exe. In my Daz Script use DzProcess() to run it as if it was being run via the command line.

        If that is a correct understanding, I would just need my exe to compile with/include/have access to the SDK code?

    2) make my code as a plugin/dll. Do I then load this dll into the plugin directory and have to enable it inside the app before it can be used? Or as long as the correct objects/functions are done in that public way those become available to be called from my ECMAscript?

        For instance, if my dll code has a public function doCoolImageThing(Image imageIn) and outputs a modified Image object, then in my Daz Script I can just write;

        var testImg = new Image("path to an image");

        var coolImg = doCoolImageThing(testImg);

    thanks again for your help!

  • bigD3d said:

    Thanks Richard,

    so if I understand you right I have these two options?

    1) make my code into an exe. In my Daz Script use DzProcess() to run it as if it was being run via the command line.

        If that is a correct understanding, I would just need my exe to compile with/include/have access to the SDK code?

    No, if you did that the application would be its own thing - it would not have any of the Daz Studio functions or data structures (beyond what you implemented).

    bigD3d said:

    2) make my code as a plugin/dll. Do I then load this dll into the plugin directory and have to enable it inside the app before it can be used? Or as long as the correct objects/functions are done in that public way those become available to be called from my ECMAscript?

        For instance, if my dll code has a public function doCoolImageThing(Image imageIn) and outputs a modified Image object, then in my Daz Script I can just write;

        var testImg = new Image("path to an image");

        var coolImg = doCoolImageThing(testImg);

    thanks again for your help!

    A plug-in's public methods are automatically available. I don't know if you could make them globals, I wouldn't think you'd want to in most cases, but you could (as I understand it) make a new Bd3dClass available to script and it would have Bd3dObject.doCoolImageThing() for an object that cotnained the image or a simple method that took the image as input and returned a new image.

  • bigD3dbigD3d Posts: 75
    bigD3d said:

    Thanks Richard,

    so if I understand you right I have these two options?

    1) make my code into an exe. In my Daz Script use DzProcess() to run it as if it was being run via the command line.

        If that is a correct understanding, I would just need my exe to compile with/include/have access to the SDK code?

    No, if you did that the application would be its own thing - it would not have any of the Daz Studio functions or data structures (beyond what you implemented).

    bigD3d said:

    2) make my code as a plugin/dll. Do I then load this dll into the plugin directory and have to enable it inside the app before it can be used? Or as long as the correct objects/functions are done in that public way those become available to be called from my ECMAscript?

        For instance, if my dll code has a public function doCoolImageThing(Image imageIn) and outputs a modified Image object, then in my Daz Script I can just write;

        var testImg = new Image("path to an image");

        var coolImg = doCoolImageThing(testImg);

    thanks again for your help!

    A plug-in's public methods are automatically available. I don't know if you could make them globals, I wouldn't think you'd want to in most cases, but you could (as I understand it) make a new Bd3dClass available to script and it would have Bd3dObject.doCoolImageThing() for an object that cotnained the image or a simple method that took the image as input and returned a new image.

    Sounds like #1 is a no-go then since I need some of the SDK Image object code. I'll move forward with #2 then and see if I can modify one of the samples in some simple way and verify my scripts can access it.

    thanks again for your help.

  • bigD3dbigD3d Posts: 75
    edited August 2020

    I wanted to let anyone reading this post that I did modify a sample plugin and was able to call if from Daz Script.

    If it helps you, go look in my follow up post at where i'm having Visual Studio/Solution/Project issues. If you are new to this like me, maybe it will be of help...

    thanks

    https://www.daz3d.com/forums/discussion/429386/got-a-sample-plugin-built-but-can-t-call-from-daz-script-solved#latest

     

    Post edited by bigD3d on
Sign In or Register to comment.