1. #1
    Member Follow User Gallery
    Join Date
    Sep 2008
    Location
    New York City
    Posts
    63

    Default switching between tools

    Hi!

    I'm trying to write some scripts that involve merging visible or booleaning which creates a new tool. Then I want to be able to switch to the new tool, do some stuff, and then switch back to the original tool. I store the item info for the original tool, then use [ISet,Tool:Item Info,9999] to switch to the newly generated tool which usually works because the newly created tool USUALLY has the highest number. However, I have found instances where this isn't the case. also, I have found that sometimes the act of creating the new tool CHANGES the Item Info value of the original tool. Obviously, this completely breaks what the script is trying to do. Any suggestions for making this work?

    thanks!

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

    Default

    Hi Ryan,

    It can be tricky keeping track of things through zscript. The way you're doing it is basically the best way. I'm not sure what circumstances cause the re-ordering you describe. I'm afraid the only way of sorting that out would be to be clear of when it happens and then adjust the code accordingly. However, make sure that you are actually seeing a change in the order - for some operations (such as cloning) ZBrush will rename the original tool/subtool. This can be confusing!

    Here are a few of other things that might help:

    You can use [ToolGetCount] to find out how many tools there are in the Tool Palette. As they are numbered starting at 0, one less than the total will be the last in the list.

    Each subtool has an ID that can be got using [SubToolGetID]. This can help identify the Tool (if you have the top subtool selected) though be warned: the ID is not unique - duplicated or cloned subtools will have the same ID.

    Names can be a useful way of tracking what's happening. You can use [ToolGetPath] to get the full path for any tool in the Tool palette without selecting it. So [ToolGetPath,49] would give you the path for the tool at position 49 (the 50th tool). You can then use [FileNameExract] to get just the name:

    [VarSet,toolName,[ToolGetPath,49]]
    [VarSet,toolName,[FileNameExtract,toolName,2]]

    Then you could compare it with a stored name:

    [VarSet,myStr,"Dog"]
    [If,(([Strlength, toolName] == [Strlength, myStr] )&&([StrFind,myStr,toolName]==0)),
    //the tool is called "Dog"

    Checking the string length makes sure the strings are the same. Without it - just using StrFind - you could look for names that contain the stored string, such as "Dog_Merged" etc.

    HTH,

  3. #3
    Member Follow User Gallery
    Join Date
    Sep 2008
    Location
    New York City
    Posts
    63

    Default

    thanks! Is there a way to change the ID number of a tool?

Posting Permissions

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