ZBrushCentral

"If "Routines in Zbrush

I am trying to get a override function to work. For example I have a script that loads a custom Ztool. Problem is every time I press the button it loads a new copy of the tool. How would I write a script that would overide the load function if the tool was already present.
Basic idea example:
code ?= if tool present do not load
code?= if not present load tool

Johnny

Hi JB,

Take a look at [IExists, TOOL:name of your tool]

[If, [IExists, TOOL:Frognose] == 0,
[FileNameSetNext, Frognose.ztl]
[IPress, TOOL:LoadTool]
]

Sven

Tried your script idea getting interface defition error.

Copy of my script

//RECORDED ZSCRIPT 2.0
[IButton,SoftBush,
[If,[IExists,TOOL:FiberBrushSoftBhshels]==0,
[FileNameSetNext,“ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL”]
[IPress,TOOL:Load Tool]
]

Fix it error needs closing bracket==0,]

//RECORDED ZSCRIPT 2.0
[IButton,SoftBush,
[If,[IExists,TOOL:FiberBrushSoftBhshels]==0,]
[FileNameSetNext,“ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL”]
[IPress,TOOL:Load Tool]

Thanks with your help will be posting my first scripts soon.

Your first code returns an error because you’ve missed off the end IButton bracket. Your second code won’t actually do what you want because the If statement’s not doing anything.

Try the following:


[IButton,SoftBush,"Load SoftBush",
[If,[IExists,TOOL:FiberBrushSoftBhshels],
//following commands for when If is TRUE
[IPress,Tool:FiberBrushSoftBhshels]
,//else
//following commands for when If is FALSE
[FileNameSetNext,"ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL"]
[IPress,TOOL:Load Tool]
]//end if
]//end button

Note: I’ve added in an IPress to select the tool if it is already in the tool palette. You may or may not want this functionality.

EDIT: Oops missed the end If bracket off myself :o

need 2 [Note Commands
1: let the user be aware the tool can not be found.
2: let the user know were the tool can be found at.


[IButton,"SoftBush","Load SoftBush",
[If,[FileExists,"ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL"],
[FileNameSetNext,"ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL"]
[IPress,Tool:Load Tool]
[Note,"\Cc0c0c0Tool \Cffa000Ready.",Tool:Item Info,999]
,[Note,"This Tool Can Not be found...",][exit]]]

It often helps to set up your code with tabs, it makes it easier to follow while you are scripting ( I know it is impossible in the forum to have it like that unless you copy/paste it). (I edited this part because it sounded too harsh to me, don’t mean to be harsh,just helpfull)

The problem I see is that your Note has extra ','s in it.
If you want a long catenated note, use StrMerge, Also see a Space in your “Tool:Item Info” Make sure this is surrounded by quotes.
Try This:

[IButton,"SoftBush","Load SoftBush",
         	[If,
         		[FileExists,"ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL"],
  		[FileNameSetNext,"ZBRUSH_ZScripts/BGroundMaker/FiberBrushSoftBhshels.ZTL"]
         		[IPress,"Tool:Load Tool"]//use quotes here for space
 		[Note,[StrMerge,"\Cc0c0c0Tool \Cffa000Ready.","Tool:Item Info"," ","999"]]//use quotes here for space // and StrMerge
         		,
         		[Note,"This Tool Can Not be found..."]
         		[Exit]
         	]
         ]
Best Of Luck, Chris Reid

im not sure about extra ','s in it
it still seams to work well
by the code you added, you lost the “Pointer” to the tool pallet
that was listed under (2)
2: let the user know were the tool can be found at.

the space has no effect
you can have “Tool:Item Info” or “Tool:ItemInfo”

Got it working based on latest code you guys suggested.
I figured it needed a if and else statement but did not know

]//end if
]//end button

about the double-end brackets overlooked that.

Thanks Sven,Marcus,Chrisand and Ad. Plan to post my plugins around the next release of Zbrush just to add to the excitement. Should not be long now. My Zscripts are workflow enhancers. I am using some of them now and it make things so much more easier. I will give you guys props of course when I post them.

Thanks again

JB

the space has no effect
you can have “Tool:Item Info” or “Tool:ItemInfo”
It is best practice to use quotes around strings with spaces. Some script objects have trouble with this.

you lost the “Pointer” to the tool pallet
I was under the impression that he was just trying to show user where it is by using the name. I can’t see what the use of the pointer would be in this situation with the note.
Oh Well, he got it working and I am glad. I maybe didn’t understand the question.

Alls good,

Chris

Is it a good idea to add notes and pointers to the script? It is bloating the code. I have all the tools in the folder and it works fine. Is this something I should add to the code to avoid errors or if items get misplace by new users?

Why the ‘999’ ? If you want the Note to stay there until the user clicks the mouse or presses the spacebar, just put ‘0’.

If you don’t want it, don’t add it. Notes are simply a way of informing a user of what’s happening. They’re not necessary in order to make things run smoothly. I use Notes when I want to make it clear to a user what’s just happened or what they should do next. But whether you use them or not is up to you.

Thanks Marcus for the insight. When I finish optimizing my Zscripts I will add notes in places where a user may get lost.

you really dont need any numbers
this will work
Tool:Item Info]

i was thinking of [ISET which any new item that is added, will add a higher number# in the tool pallet on any new item that is added, it will allways be the highest number thats why i chose 999 so it wouldn't pick up any other tool number but then again thats only for [ISET

OK, but the comma will confuse ZB into thinking it’s part of the note commands.

The easiest way to find out the last item in the Tool palette is to use:
[IGetMax,Tool:ItemInfo]. Then you can use that to select the tool with ISet.
To point out the tool just loaded, it’s simplest to use the tool name, using FileNameExtract or whatever.