Create a product by script

Hi,

I try to develop a script that creates a Product by script in the way You do it manually by right clicking a folder in the Content Pane and selecting Create Product.

The script should use the folder name as name for the product.

With some AI help I cam already this far:

(function(){
    
    var oPaneMgr = MainWindow.getPaneMgr();
    var oContentPane = oPaneMgr.findPane("DzContentLibraryPane");

    if (!oContentPane) {
        MessageBox.warning("Content Library Pane not found.", "Error", "OK", "");
        return;
    }

    // 1. Ensure a container is actually selected
    var oContainer = oContentPane.getSelectedContainer();
    if (!oContainer) {
        MessageBox.warning("Please select a folder in the Content Library first.", "Selection Required", "OK", "");
        return;
    }

    // 2. Get the Action Manager
    var oActionMgr = MainWindow.getActionMgr();
    
    // 3. Find the "Create Product From..." action
    
var oAction = oActionMgr.findAction("DzContentCreateProductAction");

    if (oAction) {
        oAction.trigger();
    } else {
        // Fallback: Try to trigger via the explicit menu command logic 
        // if the action ID differs between versions
        var sMessage = "Could not trigger 'DzContentCreateProductAction' automatically.\n\n";
        sMessage += "Ensure the folder is selected and use the right-click menu: \n'Create Product from Selected Container...'";
        MessageBox.warning(sMessage, "Action Not Found", "OK", "");
    }

})();

But it fail on  "DzContentCreateProductAction", because this Action is unkown. I tried to find the correct action name in the scripting docs and a way to pass the name,
but couldn't find it.
Is this even possibe to do?

Thanks for helping

Comments

  • Lonesome CowboyLonesome Cowboy Posts: 167

    hmmm ... it should be possible to add an action, but i guess this is not creating a product.

    I also searched the web on sites like https://dazstudioexperts.com/?s=DzContentCreateProduct but without result.

    The AI sometimes tells about commandments that do not exist.

    Tell this your AI. It might find an alternative as it did in my script below.

    By the way: which ai are you using? i made good experiences with Claude.ai

  • sidcarton1587sidcarton1587 Posts: 93

    The AI is not going to do a good job without a lot of context, especially type specification that clearly defines the valid method signatures. I created a spec as part of another project that might be useful for some of the things you all are doing. See here: https://github.com/bluemoonfoundry/daz-mcp-server/blob/master/daz_script_spec.d.ts

  • Seven193Seven193 Posts: 1,153
    edited May 18

    A DAZ MCP lets Claude interact with your Daz Studio app while it's running, correct?  So, Claude doesn't actually need a MCP to write Daz script. I think you just need to use Claude Code, not Claude Chat.  Claude Code already knows how to write C/C++, Python, etc...  MCPs aren't used for that. If you want Claude take control of Daz Studio, and do some mindless posing or whatever (pose this figure in a sitting position), then a MCP is necessary.

    Post edited by Seven193 on
  • sidcarton1587sidcarton1587 Posts: 93

    Seven193 said:

    A DAZ MCP lets Claude interact with your Daz Studio app while it's running, correct?  So, Claude doesn't actually need a MCP to write Daz script. I think you just need to use Claude Code, not Claude Chat.  Claude Code already knows how to write C/C++, Python, etc...  MCPs aren't used for that. If you want Claude take control of Daz Studio, and do some mindless posing or whatever (pose this figure in a sitting position), then a MCP is necessary.

    That is accurate. I was pointing to the spec file specifically and not the MCP server that uses it for those things you mentioned. Giving an LLM a spec helps generate more correct code. The challenge is that the full spec used directly would consume a lot of context. You want to front this with some tool or resource that the LLM can leverage.
     

     

     

  • Seven193Seven193 Posts: 1,153
    edited May 19

    So, this project, daz-mcp-server, lets Claude control Daz Studio through the scripting API.  Claude doesn't manipulate Daz Studio through the menu commands like a human. Can I ask, how you're using it now, aside from creating Daz scripts?  Are you using it to pose characters, setup animation, or other tedious tasks related to scene management?

    Post edited by Seven193 on
  • sidcarton1587sidcarton1587 Posts: 93
    edited May 19

    Yes, it's also part of a set of things I've been working on that essentially is driving to being able to craft and manipulate scenes using natural language and other tooling that DAZ script by itself doesn't naturally provide. The idea is to be able to incorporate DAZ Studio as one component in a larger production workflow. 

    The MCP server is in the infant stages right now. There are a lot of tools it exposes that do address posing, camera controls, lighting, animation setup, rendering, and so on. It's still very much in alpha form as far I am concerned, with a lot of testing to go. 

    The MCP server builds on the DAZ Script Server plugin, which is more mature. It's a Studio plugin that integrates a web server into Studio that allows users to execute inline DAZ script at a published endpoint, collect and return log output from the script, and get an actual return object from the script, formatted as JSON. I've also added a Python binding that uses the script server on the backend and adds a set of Python APIs to leverage Python's language capabilities to do things that DAZ script is bad at natively. See https://github.com/bluemoonfoundry/daz-script-server

    So the overall goal is allow users to work in the space where they feel comfortable and need the help. The MCP server is the interface for AI enabled workflows, but you can also use the script server directly without any LLM involvement and incorporate into a Python based workflow, either as a native client or as an integration point. For example, creating a sprite sheet becomes much simpler by using a Python script that can task Studio to load a scene, add a named character, pose the character by applying a preset or actually tweaking the morphs directly, light the character automatically for sprite work, render a set of images using cameras created on the fly, and combine the rendered images into a character sheet. Or if you wanted to integrate DAZ Studio renders directly into a Comfy UI workflow for post-processing, and so on. 

    If interested in following the work, check out the DAZ Director (WIP) thread in the DAZ SDK Developer Discussion forum. 

     

    Post edited by sidcarton1587 on
  • TugpsxTugpsx Posts: 874
    edited May 19

    sidcarton1587 said:

    Yes, it's also part of a set of things I've been working on that essentially is driving to being able to craft and manipulate scenes using natural language and other tooling that DAZ script by itself doesn't naturally provide. The idea is to be able to incorporate DAZ Studio as one component in a larger production workflow. 

    The MCP server is in the infant stages right now. There are a lot of tools it exposes that do address posing, camera controls, lighting, animation setup, rendering, and so on. It's still very much in alpha form as far I am concerned, with a lot of testing to go. 

    The MCP server builds on the DAZ Script Server plugin, which is more mature. It's a Studio plugin that integrates a web server into Studio that allows users to execute inline DAZ script at a published endpoint, collect and return log output from the script, and get an actual return object from the script, formatted as JSON. I've also added a Python binding that uses the script server on the backend and adds a set of Python APIs to leverage Python's language capabilities to do things that DAZ script is bad at natively. See https://github.com/bluemoonfoundry/daz-script-server

    So the overall goal is allow users to work in the space where they feel comfortable and need the help. The MCP server is the interface for AI enabled workflows, but you can also use the script server directly without any LLM involvement and incorporate into a Python based workflow, either as a native client or as an integration point. For example, creating a sprite sheet becomes much simpler by using a Python script that can task Studio to load a scene, add a named character, pose the character by applying a preset or actually tweaking the morphs directly, light the character automatically for sprite work, render a set of images using cameras created on the fly, and combine the rendered images into a character sheet. Or if you wanted to integrate DAZ Studio renders directly into a Comfy UI workflow for post-processing, and so on. 

    If interested in following the work, check out the DAZ Director (WIP) thread in the DAZ SDK Developer Discussion forum. 

     

     sidcarton1587  thanks again for the awesome tools. The Daz Script server has provided a much needed resource connection for countless applications in Daz Studio.

    Thanks for the large collection of working examples. Will continue to test and develope tools.

    Screenshot 2026-05-17 035957.png
    199 x 488 - 19K
    Post edited by Tugpsx on
  • sidcarton1587sidcarton1587 Posts: 93
    edited May 19

    Tugpsx said:

    sidcarton1587 said:

    Yes, it's also part of a set of things I've been working on that essentially is driving to being able to craft and manipulate scenes using natural language and other tooling that DAZ script by itself doesn't naturally provide. The idea is to be able to incorporate DAZ Studio as one component in a larger production workflow. 

    The MCP server is in the infant stages right now. There are a lot of tools it exposes that do address posing, camera controls, lighting, animation setup, rendering, and so on. It's still very much in alpha form as far I am concerned, with a lot of testing to go. 

    The MCP server builds on the DAZ Script Server plugin, which is more mature. It's a Studio plugin that integrates a web server into Studio that allows users to execute inline DAZ script at a published endpoint, collect and return log output from the script, and get an actual return object from the script, formatted as JSON. I've also added a Python binding that uses the script server on the backend and adds a set of Python APIs to leverage Python's language capabilities to do things that DAZ script is bad at natively. See https://github.com/bluemoonfoundry/daz-script-server

    So the overall goal is allow users to work in the space where they feel comfortable and need the help. The MCP server is the interface for AI enabled workflows, but you can also use the script server directly without any LLM involvement and incorporate into a Python based workflow, either as a native client or as an integration point. For example, creating a sprite sheet becomes much simpler by using a Python script that can task Studio to load a scene, add a named character, pose the character by applying a preset or actually tweaking the morphs directly, light the character automatically for sprite work, render a set of images using cameras created on the fly, and combine the rendered images into a character sheet. Or if you wanted to integrate DAZ Studio renders directly into a Comfy UI workflow for post-processing, and so on. 

    If interested in following the work, check out the DAZ Director (WIP) thread in the DAZ SDK Developer Discussion forum. 

     

     sidcarton1587  thanks again for the awesome tools. The Daz Script server has provided a much needed resource connection for countless applications in Daz Studio.

    Thanks for the large collection of working examples. Will continue to test and develope tools.

    Awesome! Thanks for the support. 

     

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