ZBrushCentral

Multiple ISubPalette within a loop.

Hello

I am trying to create a script for adding different subpalettes lika a library for brushes, and so far it’s going well but I’ve gotten into a couple of problems, so far nothing that can’t be solved but I’ve ended up with several cases of quite ugly code…

Here is my latest example: I want to create multiple subpalettes in the same menu. So I have made a test with a button that asks the user for a new palette name and it creates it, but it only works once.

So I created an array with different names for the subpalettes and creating each individual one is no problem if they are hard coded, but once I do it with a loop I only get the first. It seems that every [ISubPalette] command can only produce one subpalette.

Can someone explain why this is the case? And better yet, if there is workaround or method for this.

I assume it has something to do with the ID’s of the palettes, and a limitation of Zscript not being very friendly to object oriented programming.

I’ve added a small example you can try out, it will create som subpalettes in the edit menu when run.

[RoutineDef, run, 
	[Vardef, #pal_names(3)] // Array with names of the palettes
	
	[VarSet, #pal_names(0), First]
	[VarSet, #pal_names(1), Second]
	[VarSet, #pal_names(2), Third]
	
	//[Loop, 3,[ISubPalette, [StrMerge,Edit:,#pal_names(i)], 0],i] //enabling this does only produces one subpalette!

	[ISubPalette, [StrMerge,Edit:,#pal_names(0)], 0]
	[ISubPalette, [StrMerge,Edit:,#pal_names(1)], 0]
	[ISubPalette, [StrMerge,Edit:,#pal_names(2)], 0]
		
]

[RoutineCall, run]

I think that’s one of those quirks that zscript throws up from time to time. Is there any reason why you can’t just use a list of [ISubpalette] commands (as you have done) rather than a loop?

Agreed that the language is quirky :wink:

The idea was to make the user able to create every subpalette and then add buttons to it, (buttons are fine to create multiple ones with the same line for some reason :stuck_out_tongue: ) and then store everything into a config file.

Now I will resort to create a function with a lot of inactive palettes, and then add a if-check if they should be created or not, or maybe I’ll make some other functionality that doesn’t rely on subpalettes.

But saving a config file will not be enough for saving the palettes/buttons. They will only exist during the ZBrush session in which they were created, unless you make them permanent by creating a plugin.

Perhaps you could explain a bit more of what you are trying to do? So far it sounds as though you are trying to emulate the function that already exists in the ‘Customize’ section of the Preferences palette.

I have an issue where missed tasks are being triggered more than once. This only seems to happen when my computer has not been started for a few days. The following is from the nncron log:13:43:26 532 TASK missed: FTP_backup13:43:26 532 Start: E:nnCron scriptsFTP_backup.bat13:43:26 1584 TASK missed: FTP_backup13:43:26 1584 Start: E:nnCron scriptsFTP_backup.bat13:43:27 1056 TASK missed: FTP_backup13:43:27 1056 Start: E:nnCron scriptsFTP_backup.batWhat do the values 532, 1584, 1056 represent?Is there a way to stop multiple instances of the same task from being started?Thanks for any help,JB