ZBrushCentral

Question on active tool selection - help!

Hi,

I am working on a simple script which involves cloning the currently selected tool and then going back and forth between the clone and the original.

The problem is that I can’t find a way to select back and forth between the clone and the original. I thought I could simply do it through the tool number using [IGet, Tool:ItemInfo] and [ISet, Tool:ItemInfo] like this:

// Record currently selected tool number
[VarSet, activeTool, [IGet, Tool:ItemInfo] ]
// Clone the active tool
[IPress, Tool:Clone]

// Record cloned tool number
[VarSet, clonedTool, [IGet, Tool:ItemInfo] ]

// Select original tool
[ISet, Tool:ItemInfo, #activeTool]
[color=black]

The code above doesn’t work because when the tool is cloned, instead of giving the clone a new number, it gives the originally selected tool a new number and gives the clone the old number. Therefore, I can’t simply record the active tool number, clone the tool, then record the cloned tool number because it’s the same number.

I can’t figure out how to find out the new number that the cloning process gave to the original tool. Is there a way or a workaround?

Thanks

By the way, is there a way to rename the active tool?

Hi CJM,

The Tool you clone isn’t automatically selected. After cloning, the active tool is still the original.

try this:

[IPress,TOOL:Clone] [ISet,TOOL:ItemInfo,[IGetMax,TOOL:ItemInfo]] [VarSet,CloneName,TOOL:ItemInfo]

The clone has to be the newest Tool.

Also, I think if you save, then reload a Tool, the loaded Tool will have the name that you assigned to the file.

Sloppy, I know, but it’s the only way I’ve found to actually assign a name. Maybe Matthew will have a cleaner answer.

Good to see another scriptor join the hunt!

Sven

Thanks very much Sven! Getting the max number right after the clone process works just fine.

I’ll add a bit of code to Svengali 's code (Thanks Svengali:) )…

//Start by defining variables…
[VarDef,originalToolIndex]
[VarDef,originalToolTitle,""]
[VarDef,clonedToolIndex]
[VarDef,clonedToolTitle,“TempClonedTool000.ztl”]

//create a test button…
[IButton,“Test Me”,

//store the name of the currently selected tool…
[VarSet,originalToolTitle,[IGetTitle,Tool:ItemInfo]]

//clone the currently selected tool…
[IPress,Tool:Clone]

//original tool moved to the end of the list…
[VarSet,originalToolIndex,[IGetMax,Tool:ItemInfo] ]

//the cloned tool is the currently selected tool…
[VarSet,clonedToolIndex,[IGet,Tool:ItemInfo]]

//to rename the cloned tool we need to save it.
//First, advance the name of our cloned tool to avoid name conflicts…(001, 002, 003…)
[VarSet,clonedToolTitle,[FileNameAdvance,clonedToolTitle]]

//then, set the file name which will be used…
[FileNameSetNext,clonedToolTitle]

//now, save the cloned tool.
[IPress,Tool:SaveAs]

//notify user of our actions…
[Note,[StrMerge,"\Ce0e0e0Tool has been cloned and saved as: \Cff9923",[IGetTitle,Tool:ItemInfo]],29901]

//reselect the original tool…
[Iset,Tool:ItemInfo,originalToolIndex]

] // The end

Hi CJM,

One thing I love about Pixolator (thanks for posting, sir!) is he definitely has the heart of a teacher. Whenever he posts, he always takes it as an opportunity to present a concept while answering the question. EVERY time I read one of his posts, I learn something new.

:smiley: Simply by saving a tool, you also assign that file’s name to the active tool in the Tool palette. Good to know. (I assumed it had to be reloaded for the name to appear.) :smiley:

Sven

Hi again, CJM,

Actually, I learned a couple of things from your question and Pixolator’s example.

I always assumed the Tool’s cloned copy was the new one added to the list (as I wrongly explained in my reply to you above) probably because the Tool Tip (Control + hover over the Clone Button) says “The Clone Button” creates a copy of this tool in its current state, and adds it to the Tool palette." Add to that the fact that the Tool Palette display seems to verify this… (note the layout for the customized tools in the palette and the layout for the customized tools in the popup window are in a different order! :lol: )

Your original question was prompted by the fact that your code moved the original Tool giving you the same index number for original and clone… (since the clone took the original’s place.) I totally understand that now.

Of course the IGetMax command worked for you. Yet it always worked for me too, but I never really understood what Pixolator’s code demonstrates - that the original Tool moves - keeps its original name, BUT gets a NEW index number.

As I said, I learn something everytime I read a post from Pixolator. :wink: It’s just not what I thought I was learning until I looked closely at the code.

Nuff said.

Thanks again Pix…

Sven

p.s. If I’ve still got this wrong, I wish someone would let me know. :rolleyes:

Thanks very much Pixolator and Sven! Yayyyyyyyyyy

I’ve almost got my script finished but I have one final stumbling block. I posted the question here: http://www.zbrushcentral.com/zbc/showthread.php?goto=newpost&t=21003. It has to do with figuring out the way ZBrush represents object rotations. I want to synchronize light positioning with the active tool’s rotation. If you guys could take a look, I’d appreciate it a lot.

Hi,
Svengali : Your latest post is absolutely correct! and your previous one is much too kind!:smiley:
custom_junk_mail : You are welcome:) I see that the other question has been answered by Svengali (thanks again, Svengali! ) - if you are still having difficulties, I will try to post more information.
-Pixolator

P.S. custom_junk_mail :small_orange_diamond: Have you tried the InteractiveLight ZScript? its located in the ZPlugin palette and can be activated by pressing CTRL+P .