1. #1
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default "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

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Jan 2003
    Location
    NYC
    Posts
    1,626

    Default

    Hi JB,

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

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

    Sven

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default

    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]
    ]

  4. #4
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default

    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.

  5. #5
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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:
    [CODE]
    [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
    [/CODE]

    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
    Last edited by marcus_civis; 06-22-05 at 12:23 AM. Reason: correction

  6. #6
    New Member Follow User Gallery
    Join Date
    May 2005
    Posts
    6

    Default

    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.
    [code]
    [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]]]
    [/code]

  7. #7
    Senior Member Follow User Gallery
    Join Date
    May 2004
    Location
    CA
    Posts
    140

    Default

    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:

    [CODE][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]
    ]
    ][/CODE]

    Best Of Luck,

    Chris Reid
    Last edited by CHRIS REID; 06-22-05 at 09:25 AM. Reason: seemed to harsh of a comment, not intended that way

  8. #8
    New Member Follow User Gallery
    Join Date
    May 2005
    Posts
    6

    Default

    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"

  9. #9
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default

    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

  10. #10
    Senior Member Follow User Gallery
    Join Date
    May 2004
    Location
    CA
    Posts
    140

    Default

    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

  11. #11
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default

    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?

  12. #12
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Quote Originally Posted by add
    [Note,"\Cc0c0c0Tool \Cffa000Ready.",Tool:Item Info,999]
    Why the '999' ? If you want the Note to stay there until the user clicks the mouse or presses the spacebar, just put '0'.

  13. #13
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Quote Originally Posted by johnny blaze
    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?
    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.

  14. #14
    Senior Member Follow User Gallery
    Join Date
    Nov 2001
    Posts
    167

    Default

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

  15. #15
    New Member Follow User Gallery
    Join Date
    May 2005
    Posts
    6

    Default

    Quote Originally Posted by marcus_civis
    Why the '999' ? If you want the Note to stay there until the user clicks the mouse or presses the spacebar, just put '0'.
    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

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •