put subtool name in a variable ... how?

New to scripting. Can’t figure this out. This is what I’m trying to do (just a portion of my script)…

[VarSet,myVariable,[IModGet,Tool:Subtool:Subtool 0]]

Instead of "Subtool 0" I’d like to have the name I gave the subtool. (ie, head, hand, arm, etc.) I assume I need to look up the name of the subtool and insert that name where “Subtool 0” currently is. I can’t figure out how to look up the assigned name.

Ultimately I’m trying to create a script that will go through each subtool and check if visibility and polypaint is on or off.

Any help is much appreciated.

You can use [IGetTitle] to get the subtool name then use [StrMerge] to create the subtool path. See here:

[VarDef,subTName,""]//defines variable as empty string
[VarDef,subTool(1024),0]//defines a list variable to hold visibility (0 = off, on = 1)

[VarSet,totalSubTools,[SubToolGetCount]]//the total number of subtools
[VarSet,activeSubT,[SubToolGetActiveIndex]]//record the active subtool
[If,activeSubT==0,[SubToolSelect,1]]//this stops an error if the top subtool is selected but hidden in the list
[Loop,totalSubTools,  
	[SubToolSelect,[Val,n]]//selects the subtool by number
	[VarSet,subTName,[IGetTitle,Tool:ItemInfo]]//gets the tool name
	 [VarSet,subTName,[StrExtract,subTName,0,[StrLength,subTName]-2]]//trims off period at the end			
	[If,[IModGet,[StrMerge,"Tool:Sub Tool:",#subTName]]>=16,
		[VarSet,subTool(n),1]//visible								
	]  	
,n]
[SubToolSelect,activeSubT]//return to the active subtool

Note: this example uses commands introduced in ZBrush 4R4 and not available in earlier versions.

Thanks! Very helpful.