ZBrushCentral

Save As +

Hi, I am making a save as + button. I have it working actually, but it has some issues I dont know how to fix. This is what I have so far:

 
//ZBRUSH MACRO - Recorded in ZBrush version 3.5
[IButton,???,"Increment File Save",
[IShowActions,0]
[IConfig,3.5]
[VarSet,activeSubTool,[IgetTitle, Tool:Current Tool]]
[FileNameSetNext,[FileNameAdvance,[StrMerge,activeSubTool,.ztl]]][IPress,Tool:Save As]
[Note, "Saved!"]
]

This works in saving the file and increments it properly, however it isnt always in the correct file location. It takes the last used file location and saves it in that folder, I just dont know how to set the file location to where the active tool is. Also, this script will write over an existing file without asking if I open an earlier version of a ztool. How would I get it to check if there is already a file, and ask to overwrite, or skip it and save with the next increment?
Lastly, the note at the end doesnt really mean anything other than to say the script is finished, how would I get it to check if the file is actually successfully written, or, would zbrush give a save error itself and I dont need to check it in the script?
Thank you for all your help, let me know if I need to clarify anything.

hi improved save can be very usefull like auto save at bob##number
and keep last location

[IGetTitle, Tool:Current Tool] will give the full path to the file if there is one. When there isn’t a full path - such as when a subtool other than the top subtool is selected or the ztool has just been created - then your script will save the file to the folder where the script/macro resides. Note also that the default ztools such as the DemoSoldier will also fail to show a full path.

You can get the path for a file by using [FileNameExtract,#filename,1]. You could then use this to create a new file path by using [StrMerge].

You can test to see if there is already a file by using [FileExists]. You can then have a dialog asking what you want to do. The code below shows the sort of thing.


[IButton,???,"Increment File Save",
	[IShowActions,0]
	[IConfig,3.5]
	[VarDef,filename,""]
	[VarSet,filename,[StrMerge,[IGetTitle, Tool:Current Tool],".ztl"]]
	[If,[StrLength,[FileNameExtract,filename,1]]<=0,//no path
		[IPress,Tool:Save As]
	,//else we have a path so advance the file
		[Loop,1000,
			[VarSet,filename,[FileNameAdvance,filename,3]]			
			[If,[FileExists,filename],//check if the file exists
				[NoteIButton,"Overwrite"][NoteIButton,"Advance file name"][NoteIButton,"Cancel"]
				[VarSet,result,[Note,[StrMerge,"\Cff9923 A file named \Cffffff",[FileNameExtract,filename,6],"\Cff9923 exists. Please select action..."],,,4737096,,450]]
				[If,result==1,[FileNameSetNext,filename][IPress,Tool:Save As][Note, "Saved!"][LoopExit]]
				[If,result==2,[LoopContinue]]
				[If,result==3,[Exit]]	
			,
				[FileNameSetNext,filename][IPress,Tool:Save As][Note, "Saved!"][LoopExit]
			]
		]		
	]	
]

If the file is not saved successfully, for example if there’s no extension at the end of the file name, then ZBrush will throw up an error dialog. But it can be useful having a message display ‘Saved’, if only to reassure the user that the script is functioning. You could show the message in the NoteBar if you want it less obtrusive.

HTH,

very powerfull and for save canvas like psd tga
maybie save on zbr on folder for render all can be funy

so i look here http://www.pixologic.com/docs/index.php/ZScript_Command_Reference

for replace IPress,Tool:Save As] by canvas: Save As
sorry for my english

kilik128,

To save the canvas you would use:

[FileNameSetNext,filename]
[IPress,Document:Export]

The file format must be PSD, BMP or TIF.

Here’s a link to a similar plugin (called QuickSave) that I posted some time ago.

Sven

QuickSave Plugin

thank’s !
amazing forum zbc is!

What ZBrush needs is a ‘Directory Master’, a way to set all import/export for tools, models, brush etc once and for all at the start of a job in the Preference. Other apps have this options. I am just puzzled why ZBrush has not.