ZBrushCentral

get file or tool name

is there a way to get the name of the active tool? I mean when u click save tool, the default name in the save dialog. so I also need to get the default file name when u click the save file dialog. Help, my first script will not get working without this :cry:

Osamu,

After saving the Tool - I think the command to give you what you’re looking for is:

[FileNameGetLastUsed]

which returns the name of the last file saved… but includes the full path and the extension. You might then need to break it apart using:

[FileNameExtract] - see syntax in ZScript Commands List… (component specifier is 1=path, 2=filename, 4=extension).

You probably already know if you want to reference the active tool’s number, you use:

[VarSet,ToolNumber,[IGet,Tool:ItemInfo]]

Sven

edit - More info at the following link - be sure to read ALL OF THE THREAD - Pixolator explains several concepts in sample script… which clarified things for me, too! Finding Tool Identity

Hi,

Per default Zbrush uses the Item Info title as the filename when you press Save As or Export. You can use the [IgetTitle,...] command to read the current title. For example [IgetTitle, Tool:ItemInfo] could return "SimpleBrush." and [IgetTitle, Texture:ItemInfo] could return "MarbleTextureVariation1.". Notice that the returned string has a punctuation mark( . ) at the end. Keep that in mind when using the string with [[color=Wheat]FileNameSetNext,...] An example:

[FileNameSetNext, [StrMerge, [IgetTitle, Alpha:ItemInfo], “bmp”]]
[IKeyPress, 13,[Ipress, Alpha:Export]]

The [StrMerge,…] is used to add “bmp” to the [IgetTitle,…] string, resulting in a full filename, “Brush 34.bmp” for example. [Ipress,…] presses the Alpha export button and [IkeyPress, 13,…] simulates a return/enter key press so that the user does not have to press save in the save dialog window. This code will allways save the alpha as a .BMP file.

Using the string manipulation zscript commands you can change the filename in many ways, such as: Incrementing the filename by 1 each time it is saved, add a default prefix to the filename and adding tool/texture/alpha specific info to the filename.

Determining the default filename using [[color=Wheat]IgetTitle,...] can be used for Alphas, Materials, Textures and Tools. For Documents and Lights I think you must save first and use [[color=Wheat]FileNameGetLastUsed]. Perhaps pressing save combined with an [IkeyPress,...] simulating the escape key is enough for [[color=Wheat]FileNameGetLastUsed]?

When you use Tool:Save As directly, and you have a texture already assigned to the Tool, you are asked if you want to save the texture, too. If you answer yes, I think that means it gets saved as part of the .ztl file and is loaded back automatically and reassigned to the tool when reloaded at a later time.

However, I’ve found that using [IKeyPress,13,[IPress,Tool:Save As]], it doesn’t ask, and won’t save the associated texture…? Is that your experience too? Is there a work around or am I missing something?

Sven

Yes, saving a tool with a texture assigned embeds the texture within the .ZTL file. The texture is saved when I use [IkeyPress, 13,…] to complete the save dialog. Does the texture not show up when you reload the tool?

That is in fact a good point Sven, the “include texture” dialog does not appear when using [IkeyPress, 13,…]. We need to detect a texture, an alpha or both all depending on which type of tool is currently selected, and open our own note window interface.

All depending on the users wishes it is a matter of storing the current Texture/Alpha item info, deselecting the current Alpha and/or Texture ( [Iset, Texture:ItemInfo, 0] and/or [Iset, Alpha:ItemInfo,0]) and restoring the Texture/Alpha item info after the save operation is complete.

Edit: Osamu, as Svengali mentions the [FileGetNameLastUsed] returns the filename and the full path. [IgetTitle,…] does not include a path. You will probably need a full path when saving so check out this thread : Controlling Subdirectory paths in ZScript

As a matter of fact, I assumed the texture didn’t get saved (never checked after the fact by reloading) but see now, from a test, that it does!

So, I guess that means if there is no active texture, no texture gets saved… (duh). So your sequence of operations would effectively simulate what happens, and your code would offer the option to save or not save just like it does now, with Save As, interactively. Oh, yeah, and I see that the option for saving the alpha has to be managed too.

Next question: how do you get those thumbnails of the current texture and current alpha to display in the dialog? Hmm. I’ll have to think on that… :slight_smile:

Anyway, thanks, Mark,for pointing me towards a solution!

Sven

hi, thank u all, u guys are really quick , I really got more info than expected :lol:

Related to tool names and saving I’ve noticed something to watch out for (forgive me if this is mentioned elsewhere). If you import an alpha from a file named, for example, image.psd and then use the Make 3D command, the resulting tool will be called Skin_image. No problem there but if you immediately save this new tool, the default name will be Skin_image.psd and pressing ‘Save’ will save a file with the .psd extension. It will be a .ztl file but will be invisible to ZBrush because of the .psd extension. Switching to a different tool and then back again gets rid of the .psd in the default filename.

Marcus

I guess when you get an itch you scratch it. The discussion in this thread made me realize that the PSnap buttons were always saving the Texture Maps with the Models (depending on the size of the map, that can add a big hunk of bytes to EACH file - yikes!) I have posted an update in THIS THREAD to the PSave button set which now asks if you want to imbed the current Texture Map with the saved model.

Thanks to osamu for starting this thread and for TVEyes’ suggestions on how to proceed with the Texture embedding issue.

[By the way, I solved the map thumb nail reference by simply pointing the popup query to the current Texture :)]

Sven