ZBrushCentral

Procedurally adding isubpalette/ibutton

Hi folks,

I am trying to mimic the mechanism of the reload all macros button.
Unfortunately, i get a nasty issue when i am using a loop i declare the isubpalette and the ibutton.

Here i post two macros the first one doesn’t works ( use [loop])
and the second macro works properly for the creation of the ui items.

[RoutineDef, Hello_World,
	[Note, [StrMerge, message, " :: ", item]]
,message, item]

[IButton, "???", "Add subpalettes and button UI",
	[If, [IExists, "Zplugin:Testing"],
		[IClose, "Zplugin:Testing"]
		[ISubPalette, "Zplugin:Testing"]
		,//else
		[ISubPalette, "Zplugin:Testing"]
	]
	[Loop, 5,
		[VarSet, path, [StrMerge, "Zplugin:Testing:", n]]
		[If, [IExists, path],
			[IClose, path]
		]
		[VarSet, text, [StrMerge, "button-", n, " was pressed."]]
		[IButton, path,"tooltip !",
			[RoutineCall, Hello_World, text,n] //  < don't pay attention to that )
		,0,1]
		[Note, [StrMerge, path,"\n"],,-1]
	,n]
	[Note,]
,,1]

but this one works :

[RoutineDef, Hello_World,
	[Note, [StrMerge, message, " :: ", item]]
,message, item]

[IButton, "???", "Add subpalettes and button UI",
	[If, [IExists, "Zplugin:Testing"],
		[IClose, "Zplugin:Testing"]
		[ISubPalette, "Zplugin:Testing"]
		,//else
		[ISubPalette, "Zplugin:Testing"]
	]
	[VarSet, i , 0]
	[IButton, [StrMerge, "Zplugin:Testing:", i],"tooltip...",
		[RoutineCall, Hello_World, "button was pressed.", [Var, i]]
	,,1]
	[VarInc, i]
	[IButton, [StrMerge, "Zplugin:Testing:", i],"tooltip...",
		[RoutineCall, Hello_World, "button was pressed.", [Var, i]]
	,,1]
	[VarInc, i]
	[IButton, [StrMerge, "Zplugin:Testing:", i],"tooltip...",
		[RoutineCall, Hello_World, "button was pressed.", [Var, i]]
	,,1]

	[Loop, 5,
		[VarSet, path, [StrMerge, "Zplugin:Testing:", n]]
		[If, [IExists, path],
			[IClose, path]
		]
		[VarSet, text, [StrMerge, "button-", n, " was pressed."]]
		[IButton, path,"tooltip !",
			[RoutineCall, Hello_World, text,n]
		,0,1]
		[Note, [StrMerge, path,"\n"],,-1]
	,n]
	[Note,]
,,1]

If someone has any idea, because i can’t to not use [Loop] for such of purpose :thinking:

Nicolas

hey @marcus_civis any thought ?

Hi Nicolas,

I don’t really have any ideas, I’m afraid. I suppose it might be to do with how ZBrush processes and stores zscript in memory which is not necessarily strictly in the order it is written. For example, I have had issues where a Note will show earlier than expected.

Marcus

so for those who like to make something similar.
I think the only way is to change the method, so I create a custom menu and have a plugin which load all scripts where each ibuttons are properly defined.