Adding scripts to DS Scripts Menu

I'd like to write an install script that copies files from an unzipped file collection into a DS Content Library location.

Once the files have been copied, I'd like to add them to the DS Scripts Menu. That would involve adding a new Submenu to the Scripts Root Menu, and programatically invoking 'Create Custom Action'.

Is there a way to do this with DS Scripts? 

Comments

  • As I recall you want DzActionMgr

  • Thanks Richard. I got it working. 

    In case others have an interest in this operation, here's my code example.

    // Add Custom Actions to Daz Studio's main menu// Author: Richard Penney// Date: 11/18/2019// Get the applications's main menuvar oMainActionMenu = oActionMgr.getMenu();// Get the Scripts menu itemvar oScriptsMenu = oMainActionMenu.getSubMenu("&Scripts");// Some Daz Workspaces do not show a Scripts menu - so add it if missingif (!oScriptsMenu){	var numItems = oMainActionMenu.getNumItems();	oMainActionMenu.insertMenu("&Scripts", "", numItems-2);	if (!oScriptsMenu)		return;}// Now that we have a Scripts menu, we can add Custom Actions to it// We'll add a submenu named FooBar// We check to see if it already existsvar oSubMenu = oScriptsMenu.getSubMenu("FooBar");if (!oSubMenu){    // go ahead and add it	oScriptsMenu.insertMenu("FooBar", null, -1);	oSubMenu = oScriptsMenu.getSubMenu("FooBar");}// Now that we have a FooBar submenu, we can add Custom Actions to itvar dstFile = "someFilePath";var uid; // the Guid to identify the action// First, create an action and retrieve the Guiduid = oActionMgr.addCustomAction("Create a Foo Action", "Foo Dialog", dstFile, true, "", "");// Insert the action. Passing -1 as the second parameter will automatically increment the index for usoSubMenu.insertCustomAction(uid, -1 );// Create another actionuid = oActionMgr.addCustomAction("Create a Bar Action", "Bar Dialog", dstFile, true, "", "");// Insert the actionoSubMenu.insertCustomAction(uid, -1 );// Finished!

     

  • I think that will fail if there's no Scripts menu as you are not refreshing oScriptsMenu after attempting to add the Scripts menu and then you return if the object isn't valid, which of course it isn't or the conditional code wouldn't be executing.

  • Thanks Richard. I'm now refreshing oScriptsMenu by reassigment, as shown below.

    var oScriptsMenu = oMainActionMenu.getSubMenu("&Scripts");

    Is this the correct way of doing it? 

    Other than that, my script works fine.

  • Thanks Richard. I'm now refreshing oScriptsMenu by reassigment, as shown below.

    var oScriptsMenu = oMainActionMenu.getSubMenu("&Scripts");

    Is this the correct way of doing it? 

    Other than that, my script works fine.

    Looks right to me, yes.

Sign In or Register to comment.