ZBrushCentral

Appending one tool to another in a script

Hi,
I’m trying to write a script in which one tool will be appended to another tool, however I’m hitting a bit of a problem. I’ve recorded the script to find

[IButton,Play,“Press to play this ZScript. ZScript can be aborted at anytime by pressing the ëescí key.”,
[IConfig,3.5]
[IPress,Tool:SubTool:Append]
[IPress,PopUp:NewTool]
]/End of ZScript/

which should append the tool called ‘NewTool’ to the original tool selected, however it always comes back with the error

‘Zscript Note: Interface item could not be found’
PopUp:NewTool
in…
[IPress,PopUp:NewTool]’

There’s definatly a tool called ‘NewTool’ in the popup menu but the script can’t seem to find it. If anyone could help it’d be much appreciated :slight_smile:

Attachments

ZscriptError.jpg

There’s an issue where the name for the tool that ZBrush stores internally doesn’t always agree with the displayed/recorded name and that causes the error. The solution is to get the full name of the tool you want to append and store it in a variable. The code below assumes that the tool you want to append is the most recent tool to be loaded (and therefore the last in the ‘Item Info’ slider at the top of the Tool palette). You should be able to easily adjust the code if necessary.


[IButton,Play,"Press to play this ZScript. ZScript can be aborted at anytime by pressing the ëescí key.",
[IConfig,3.5]
//store the current tool ref:
[VarSet,toolID,[IGet,Tool:Item Info]]
//switch to the tool you want to append:
//(this code assumes that the append tool was the most recently loaded)
[ISet, Tool:Item Info,[IGetMax,Tool:Item Info]]
//get the name of the append tool:
[VarSet,appendTool,[IGetTitle,Tool:Current Tool,0]]
//switch back to the main tool:
[ISet,Tool:Item Info,#toolID]
//append the tool:
[IPress,Tool:SubTool:Append]
[IPress,[StrMerge,"PopUp:",#appendTool]]
]/*End of ZScript*/

that worked great, cheers :smiley:

Hey guys, one more thing i’m stuck on trying to get my script to work.
I’m trying to put in an IF statement which checks if the subtools name is the same as a previously stored variable. Unfortunatly even where the variables store different things in them it see’s them as the same. Again if anyone could help it’d be a big help. Heres my code:

//Store the first variable
[VarDef,EnvName,“Tool:EnvText”]
[IButton,“Offset”, Merge and tile the visible subtools,
[IConfig,3.5]
//Store the selected subtools path
[VarSet,EnvText,[IGetTitle,Tool:Current Tool,1]]
[Note, EnvText]
//check to see if both variables are the same
[If, EnvName=EnvText,
[Note, “Fail”]
,
[Note, Success]
]
]

Yes, you can’t do it like that.

Try this:


[If,(([StrLength,EnvName]==[StrLength,EnvText])&&([StrFind,EnvName,EnvText] > -1)),
   [Note,"They're the same"]
,
   [Note,"They're different"]
]

thanks again :slight_smile: One last thing, i’m now trying to merge my visable subtools, append the resulting tool back into my original tool and select the merged subtool. It all works until I want to select my merged subtool. My script looks like this

//Set name for original tool
[VarSet,ToolNom,[IGet,Tool:Item Info]]
[IPress,Tool:SubTool:Merge Visible]
//Select Merged Tool
[ISet, Tool:Item Info,[IGetMax,Tool:Item Info]]
[VarSet,cloned,[IGetTitle,Tool:Current Tool,0]]
[VarSet, SubSelect,[StrMerge,“Tool:SubTool:”,Cloned,]]
[VarSet,Popcloned,[StrMerge,“PopUp:”,Cloned,]]
//Select Original Tool
[ISet,Tool:Item Info,ToolNom]
//Append Merged Tool
[IPress,Tool:SubTool:Append]
[IPress,Popcloned]
//Select new subtool
[IPress,SubSelect]

It dosn’t seem to be able to find the name of the new subtool, i’m guessing this is due to the same reason you can’t select tools by name. Is there a way of selecting a subtool by number or selecting the latest subtool created?

The script can’t find the new subtool because it isn’t visible in the subtool list. This will happen if the number of subtools is >7. The solution is to set the scroll bar so that the last subtool (the newly appended one) is visible:


//Select new subtool
	[ISet,Tool:Sub Tool:SubTool ScrollBar,0,0]
	[IPress,SubSelect]