ZBrushCentral

Problem with tools renaming themselves and "append"

So I found what seems to be a funny bug of some sort. Here is my situation:

I have the DemoSoldier_1 Tool and then I have 3 OBJs that I want to import.
I have Teapot01.obj, Teapot02.obj and Teapot3.obj
I’m working on a script to auto import objs and auto append them to the currently selected tool if they don’t match an existing subtool.
So I go one by one, first the zscript checks if Teapot01 is already a subtool. In this case it’s not, so it switched to SimpleBrush and imports the obj. It then saves the current tool (Teapot01) with:

[VarSet,appendTool,[IGetTitle,Tool:Current Tool,0]]

Goes back to the DemoSoldier and appends it with:

[IPress,Tool:SubTool:Append]
  [IPress,[StrMerge,"PopUp:",#appendTool]]

So far so good. Now, Teapot02 comes next. It also isn’t an existing subtool so it switches to Simplebrush once again, it is then imported. I switch back again to DemoSoldier_1 and I append it, using the very same code I used above. To my surprise it actually appends the first Teapot again!!
Now, I think I have found out why this happens. Turns out, that the moment I append Teapot01 to DemoSoldier, the original Teapot01, (the one that is not appended) is renamed to Teapot02. So when I import Teapot02.obj I have two tools called Teapot02.
The problem comes when I append the tool with

[IPress,Tool:SubTool:Append]
  [IPress,[StrMerge,"PopUp:",#appendTool]]

It seems to look for a Teapot02,but it just randomly picks one of them. Is there any way around this?

Yes, this is something you need to code for. The simplest solution is to change the name of the imported tool after it has been appended. You can do this by importing a different OBJ on top. So long as the tool has no subdivision levels it will be replaced by the newly imported tool and its name changed. You might have a ‘Polymesh3D’ obj stored in your plugin’s data folder expressly for this purpose. The Tool palette will then contain only tools named Polymesh3D and the next imported tool will be appended correctly.

You might go one step further and use this method to control scaling of the imported OBJs:

  1. Clone the top subtool.
  2. Switch to the clone and delete its subdivision levels.
  3. Import the first OBJ to be appended and store its name in a variable.
  4. Switch to the original tool and append the new subtool.
  5. Switch back to the imported OBJ (that was the clone) and repeat steps 3 - 5 as necessary.

HTH,

Hah! Nice workaround! Thanks again! You are the man! :smiley: