ZBrushCentral

Question: insert the tool from a file?

I would like to load and insert some ZTL to my subtool.
But, I don’t know why this script say, " ‘PopUp:TheCube’ does not exist." in the last [IPress,PopUp:TheCube].

[IButton,???,"SandBox",
	
	[IF,[IExists, Tool:TheCube] //if it exists this cube also was loaded from file.
	,// true
		// nothing to do
	,//else
		[VarSet,current_tool_index,[ToolGetActiveIndex]] //get current tool index
		
		[FileNameSetNext,"ZBRUSH_/ZStartup\Macros\test\TheCube.ztl"]
		[IPress,Tool:Load Tool]
		[ToolSelect, [Var,current_tool_index]]
	]

	[IPress,Tool:SubTool:Insert]
	[IPress,PopUp:TheCube]
]


Hi,

The internal subtool name can vary so when using zscript you need to do something like this, to get the name of the subtool:

[IButton,???,"SandBox",
	[VarDef,currentSubTool,""]
	[VarSet,currentToolID,[ToolGetActiveIndex]] //get current tool index
	[If,[IExists, Tool:TheCube] //if it exists this cube also was loaded from file.
	,// true
		[IPress,Tool:TheCube]	
		[If,([ToolGetActiveIndex]== #currentToolID),
			[Note,"Can't insert SubTool to itself!",,2]	
			[Exit]
		]		
	,//else			
		[FileNameSetNext,"ZBRUSH_/ZStartup\Macros\test\TheCube.ztl"]
		[IPress,Tool:Load Tool]	  		
	]
	[VarSet,currentSubTool,[IGetTitle,Tool:Current Tool,0]]
	[ToolSelect, [Var,currentToolID]]
	[IPress,Tool:SubTool:Insert]
	[IPress,[StrMerge,"PopUp:",[Var,currentSubTool]]]	
]

Also, I think it’s best to avoid using underscores in variable names (they are OK in MemBlock names).

HTH,
Marcus

1 Like

Yes I confirm that underscore in the variable name for Macro is not a good idea and will mostly fail to compile as ZSC file. But I use that for plugin and script for long time now, and it works fines in that case.

Hope it helps,
Nicolas

1 Like

I totally misunderstood this script like as" inserting top subtool of the selected tool".

[IPress,Tool:SubTool:Insert]

It was huge ditch for me. Thank you for the example kindly :smiley: . And, yes, I change the variables to none underscore name.

Thank you @marcus_civis and @facelessmindz sincerely!

2 Likes