ZBrushCentral

[Solved] Hide/Unhide a Specific folder

Hello, I was trying to make simple script that would toggle visibility of one specific folder named “Unused”. The idea would be that I could dump there subtools I dont want to be visible for the moment, so I could quickly unhide/show all if I need to and then use this script to quickly hide the undesired oned.

I believe this is a simple syntax error, because when I put the .txt file in the Macros folder, the .zsc file is not created when booting up ZBrush. I cannot figure out the problem:

[IButton,???,"Hide Unused",
	
	[If,[IModSet,Tool:SubTool:Unused]==0,    	//If the "Unused" folder is not visible...
		[IModSet,Tool:SubTool:Unused,2]		//show it...	
		,//else
		[IModSet,Tool:SubTool:Unused,0]		//else, hide it.
	]//end of if command
]//end of macro

Would anyone know what is wrong here?

Welp, I’m thinking this might not be possible the way I want it to. If I record a macro in which I only hide the folder, like such:

//ZBRUSH MACRO - Recorded in ZBrush version 2021
[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ëescí key.”,
[IShowActions,0]
[IConfig,2021]
[IModSet,Tool:SubTool:Cloth Ref,2]
]

…it will just pop up an error when executed. So much for that :sweat_smile:

Hi,

Try this :

[VarDef,gEq,0]//defines return variable  StrEquals

[VarDef,gId,0]//defines return variable getIdOfFolderNamed

// Determine String equality

[RoutineDef, StrEquals,

    [VarSet, gEq,0]

[If,

    ([StrFind,str1,str2 ]>-1) && ([StrLength, str1]==[StrLength, str2]) 

    ,

    [VarSet, gEq,1]

    ,

    [VarSet, gEq,0]

]

,str1,str2]

// determine id of folder named (the foldername in parameter)

[RoutineDef, getIdOfFolderNamed,

    [VarSet,gId,-1]

    [VarSet,totalSubTools,[SubToolGetCount]]

    [Loop,#totalSubTools,  

    // get subtool name

    [VarSet,name,[SubToolGetFolderName,n]]

    // verify if name in subtool list

    [RoutineCall, StrEquals,name,folderName]

        [if,gEq,

          [VarSet, gId,n] // set return value id

          [LoopExit]

        ]

    ,n]

  

,

folderName ]

//ui

[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ëescí key.”,

    // declare folder name

    [VarSet,folderName,"Unused"]

    // get id folder named Unused

    [RoutineCall, getIdOfFolderNamed,folderName]

  

  [If,gId==-1,// if id not found

    [Note,[StrMerge," No folder named ",folderName]]

  ,//else if id found use id with SubToolGetStatus

    [If,[SubToolGetStatus,gId]==2065, // not sure about those values 

            [SubToolSetStatus,gId,2067]     

            ,//else

            [SubToolSetStatus,gId,2065]     

        ]//end of if command

    ]

]

Hi,

See my answer here:

HTH,
Marcus

@tpqz_draw Thank you for taking the time to reply - I tried your script, and it hides the folder successfully. However, it does not make it show up again, and I’m not entirely sure what to modify there to make it work as a toggle, if possible.

@marcus_civis Thank you Marcus, I was able to create two scripts based on your explanations - one to show the folder, and one to hide. Is there a way I could make that RoutineCall toggle the “turnOn” flag? I tried checking for its status in an If statement, so as to decide whether to show or hide, like this…

[If,[RoutineCall,ToggleFolder,“unused”,turnOn==0], //If the “Unused” folder is not visible…

or…

[If,[ToggleFolder,“unused”]==0, //If the “Unused” folder is not visible…

But this doesn’t cut it. Is this possible to do, with the way a RoutineCall is composed? And if so, could you give any pointers on how to do it?

Hi,

Yes, that won’t work. You can’t include a RoutineCall in an If statement as the RoutineCall itself can’t be evaluated to true or false.

The simplest way to do what you want is to rewrite the routine so that it toggles the folder off or on as necessary:

//routine to turn Folder on/off using name
[RoutineDef,ToggleFolderOnOff,	
	//loop until a folder is found
	[Loop,[SubToolGetCount],									
		[VarSet,folderIndex,[SubToolGetFolderIndex,[Val,n]]]
		[VarSet,st,[SubToolGetStatus,[Val,n]]]										
		[If,folderIndex > -1,	//if we have a folder	
			//check the folder name is the one we want
			[VarSet,folderName,[SubToolGetFolderName,[Val,n]]]
			[If,(([StrLength,name]==[StrLength,folderName])&&([StrFind,name,folderName]==0)),
				//if it's the folder we want	
				[If,([Val,st]&0x01 == 0x01),//if it's ON - turn off						
					[SubToolSetStatus,[Val,n],0x00]
				,//else
					[If,([Val,st]&0x00 == 0x00),//if it's OFF - turn on
						[SubToolSetStatus,[Val,n],0x03]						
					]
				]								
				//all done, exit loop
				[LoopExit]			
			]//end if same name
		]//end if folder					
	,n]//end loop					
,name]

You’d then call this using
[RoutineCall, ToggleFolderOnOff, "Unused"]
for a folder named “Unused”.

HTH,
Marcus

3 Likes

Amazing - works like a charm. Thank you Marcus, you’re a savior!

2 Likes