ZBrushCentral

Regarding Menus - Renaming them programmatically, saving to file & hovering panels

Hello,

I have a three-part question about creating new menus through a ZScript.

How do I create a new menu via a ZScript and give it a name? I see that I can create a new menu using the following command:

[IPress,Preferences:Custom UI:Create New Menu]

However, when I run the script, it asks me to enter a menu title manually. How do I give the menu a name programmatically?

How to save a single menu to a file? Now that I have made a new menu, I would like to save it to a separate file to share with other ZBrush users. I see that I am able to save a User Interface Configuration File, but I would like to save only the single menu I created rather than the entire ZBrush interface. That way, when another ZBrush user loads the UI file it doesn’t override their existing interface configuration. How can I save a single menu to a file that other users can add to their existing configurations?

How to lock hovering panels so that they don’t disappear when clicking away? Is there any way to lock hovering panels so that they both 1) sit on top of everything else in the interface and 2) don’t disappear when clicking away from them?

Cheers!

David

hi @davidbk
just to make you save of your time, I will just tell you you can create new palette, you can add subpalette programmatically, but you can’t to add button as all the grouped command, even if you just store a routine name, will not work at all, for that you would have to store you routine name in a persistent memory block.
I had already tried that but it fails when it starts to be interesting, unfortunately.

Hope it helps.
Nicolas

Thank you @facelessmindz, I have not used memory blocks so I am not quite sure how they would useful for me here.

Is there a way to rename a new menu programmatically?

You can’t to pass a text when you click on that button, you would have to rename it using Zfile utils library as you could just have a generic name and edit it afterward with Zfile Utils. ( and i am not sure it will work for that specific button, the Zfile utils can do it to rename subtool and layers3d or such of thing but not sure at all for the create new menu button.

So you can create the palette and subpallette like that :


[RoutineDef, Create_Palette,

    [If, [IExists, name],
        ,//else
        [VarSet, result, [IPalette, name, 0, SHIFT+"m"]]

    ]
,name,result]


[RoutineDef, Create_SubPalette,

    [If, [IExists, name],
        [VarSet, result, [ISubPalette, name, 1]]
        ,//else
        [VarSet, result, [ISubPalette, name, 1]]
    ]

,name,result]

[IButton, "???", "Create a programmatically a custom menu.",

        // close at the Subpalette level, at the palette level it gonne lead to crash ZBrush.
        [If, [IExists, "Palette:Subpalette"], [IClose, "Palette:Subpalette"]]
        [If, [IExists, "Palette"],,
		// then palette do not exists
		[VarSet, name, "Palette"]
		[VarSet, result, -1]
		[RoutineCall, Create_Palette, name, result]
		[If, result !=1,
			[Note, "The palette can't be created or already exists."]
			// [Exit]
		]
	]
	// supposedly closed so we don't check if it exists twice
	[VarSet, name, "Palette:Subpalette"]
	[VarSet, result, -1]
	[RoutineCall, Create_SubPalette, name, result]

	[If, result !=1,
		[Note, "The subpalette can't be created or already exists."]
		[Exit]
	]

,,1]

Try that if you want, it will create a new palette and a subpalette,
but everytime to try to press the button again ; the IClose on the previous palette will make ZBrush crashes to desktop. I haven’t been able to resolve that issue.

I’ve more code about creating button but it will not works as for me.

Memory block are text you get from a text file, so you can store strings and text in there.

Hope It helps!
Nicolas

Wow thanks @facelessmindz !

I will have a closer look at your script. I just tried to run it now (through the menu Zscript > Load) but I do not see any new menu named “Palette”. Should I expect to see it when I load the script?

David

yes it should create the new menu called Palette
image

Thanks Nicolas! @facelessmindz

Ok, I understand now.

I didn’t realise that I had to replace the “???” with something useful. I changed that line and added a line above it to create a sub palette for the button.

[ISubPalette, "Zplugin:Make Custom Menu"]
[IButton, "Zplugin:Make Custom Menu:Make Custom Menu", "Create a programmatically a custom menu.",

It seems to work for me now so I will experiment.

I just checked out your Puppet Master website. Looks like you’ve done a lot of Zscripting! I might reach out to you again with some questions if you don’t mind.

Thanks for your feedback!

David

PS. How do I get the proper syntax coloring (like you) on the forum posts?

oh yes i forget to tell you it was a macro :smiley:

for color syntax use three backticks ``` like that :

```c
// post your code here
```

Thank for taking a look at my website, sadly I had to stop the revamp of my stuff on it, because of a health issue, but hope I can complete and post more of what i have done with ZBrush and ZScript since 2017.

Nicolas

Thanks @facelessmindz !