ZBrushCentral

How to identify interface by their type

So I answer to my own initial question about how to identify the type of a ui item based on his path in Zbrush ui.

so we will hard code the list of Switches button, no need for io stream and read file etc… it gonna be faster that way.
here is a switch.h file with few item path which all are of type switch .

const char * switches[] =
{   
    "tool:geometry:smt", "tool:subtool:polygrp","tool:subtool:geometry", "tool:subtool:color", "tool:subtool:farthest",
    "tool:subtool:outer", "tool:subtool:inner", "tool:subtool:double", "tool:subtool:tcorner",
    "tool:subtool:tborder", "tool:geometry:suv"
}

and the code of the function in main.cpp

ZBRUSH_API float IsSwitchType(char* pStrValue, double optValue, char* pOptBuffer1, int optBuffer1Size,
	char* pOptBuffer2, int optBuffer2Size, char** zData)
{
	
	if (isdigit(*pStrValue))
		return 0.0f;

	int i = 0;
	int s = (sizeof switches / sizeof switches[0]) - 1;
	for (i = 0; i <=s; i++)
	{	
		if (strcmp(switches[i], pStrValue) == 0)
			return 1.0f;
	}
	return 0.0f;
}

zscript :

[VarSet, ERROR, -1]
[VarSet, ERROR, [FileExecute,[Var,dllName], "IsSwitchType", buttonPath]]
[If, ERROR < 0,
    [Note,"An error has occured"]
    [Exit]
    ,// else
    [If, ERROR == 1,
        [Note, [StrMerge, buttonPath, " is a switch item."]]
        ,// else
        [If, ERROR == 0,
            [Note, [StrMerge, buttonPath, " is not a switch item."]]
        ]
    ]
]

hope it helps!
Nicolas

I will not post another topic just for a simple question, but there is a way to know how many layers are available on the current subtool ?
because to move to select the desired layer, you first need to count every layers, so after that, you can finally use the [ISet, "tool:layers:layers scrollbar,0, count-inc] to move the scrollbar.
But to be honest it would be simpler if we could have this information from :

  1. a new zscript command [LayerGetCount] just like for subtools.
  2. or store that info so we can access it using [IGetInfo, button:path]
  3. or add a new button in preferences:misc:layers
  4. or add that in [MeshIGet].

Hi Nicolas,

You can get the number of layers like this:

//****routine to find the number of layers*****************
[RoutineDef,GetLayers,
	[VarSet,numberOfLayers,0]
	[If,[IsEnabled,Tool:Layers:Layers Scrollbar],//if there's a scrollbar there is more than	one layer	
		//store current scroll bar position
		[VarSet,tmpLyScrPos,[IGetSecondary,Tool:Layers:Layers Scrollbar]]
		//set scroll bar to a maximum to ensure it is at the top
		[ISet,Tool:Layers:Layers Scrollbar,0,256]
		[VarSet,numberOfLayers,[IGetSecondary,Tool:Layers:Layers Scrollbar]+1]
	,
		[If,[IsEnabled,"Tool:Layers:Layer Intensity"],
			[VarSet,numberOfLayers,1]	
		]
	]
,numberOfLayers]//end routine

HTH,
Marcus

1 Like