ZBrushCentral

loading and saving iterations in a script

Hi there,

Im making a script that will (hopefully) pump out OBJs and Normals for hundreds of ZTLs for a job we’re working on.

The idea is to create a relatively short script and have it repeat itself adding an iteration of 001 each time it goes though, saving normals and
objs as it goes.

Is there an easy way to create a script that, once it gets to the end, returns to the start and adds + one to the process untils its done?

Thanks

Hi Ed,

Take a look at this brilliant little batch utility by Cameyo, one of the great old-time scripters here at ZBCentral. I’ve used it to process whole directories of ztool files by plugging in simple ZScript code.

batch file utility creates ZScript file

You should be able to adapt the scripting to what you need.

Sven

Thanks Sven,

Tho I have to admit, I dont know how this helps me… its been a long friday and doing a thousand things at a time.

Im really just looking at a way I can add an increment of one to each loop for the imported file, and so to the exports.

Sorry for my lack of understanding, I’ll be able to have a proper look at the program over the weekend.

This is the script test so far, below any other assistance would be appreciated.

Cheers

[IButton,“Normal OBJ”,“Read TXT to learn more. ZScript can be aborted at anytime by pressing the ‘esc’ key.”,

[IShowActions,0]
[IConfig,3.1]

[Loop,3,
[VarDef,counter,0]
[VarSet,counter,(counter+1)]
[Note, counter,80]

[FileNameSetNext,“X:\00_Current\BMW_clay\zbrush\x6closeup\Ed_frames\x6_KeyFramex6_01.ZTL”][IPress,Tool:Load Tool]
[CanvasStroke,(ZObjStrokeV02n2=H1D5V161H1D5V161)]

[IPress,Transform: Edit]
[ISet,Tool:Geometry:SDiv,2]
[IUnPress,Tool:Export:Grp]
[IPress,Tool:Export:Mrg]
[FileNameSetNext,“X:\00_Current\BMW_clay\data\OBJs\x6_KeyFramex6_01.obj”][IPress,Tool:Export: Export]
[ISet,Tool:NormalMap:NMRes,4096]

[IPress,Tool:NormalMap:Tangent]
[IPress,Tool:NormalMap:Adaptive]
[IPress,Tool:NormalMap:SmoothUV]
[IPress,Tool:NormalMap:Create NormalMap]
[IPress,Texture:x6_KeyFramex6_01]
[FileNameSetNext,“X:\00_Current\BMW_clay\sourceimages\Normals\x6_KeyFramex6_01.tif”][IPress,Texture:Export]

] //end of Loop

]/End of ZScript/

You can do this by using the FileNameAdvance command. This will increment the index of a file for each iteration of the loop, so you don’t need a counter. Then all you need to do is add in the new file name to the path and extension for each operation using the StrMerge command. See the text file for how it’s done.

Note about your code: the counter as you have it will not work. You have the VarDef inside the loop. This will re-initialize the counter to 0 for each iteration.

Cheers Marcus,

Will give this s try. Thanks for the info about errors as well.

Thanks to you both for your time.

Edit: Marcus, I see now that you have added to the script with explainations of it function. Thanks so much, this is the sort of thing I could waste days getting info on. It makes everything very clear. Much appreciated.

Ed

One last question,

Is there a way to clear the tools without Initializing or Restoring config? As we will potentially be importing hundreds of tools in it would be preferable to clear the tools that have been used completely. I assume that you cannot initialize during running a script and pressing R doesnt seem to remove the tool completely.

Am I wrong?

Thanks again

You can use:

[IKeyPress,13,[IReset,3]]

to reset the tool palette but be aware that it will clear all ztools (saved or not) without warning. You might want to clear the canvas before using it.

However, there’s no way to clear the alpha or texture palette and you will find that a build up in those palettes will likely impact performance. I think you will probably need to restart ZBrush after processing every hundred or so.

brilliant, this is working like a dream.

Thanks again Marcus