1. #1
    Senior Member Follow User Gallery
    Join Date
    Aug 2005
    Posts
    401

    Default 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

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Jan 2003
    Location
    NYC
    Posts
    1,626

    Default

    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

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Aug 2005
    Posts
    401

    Default

    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\x6c loseup\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\sourceimag es\Normals\x6_KeyFramex6_01.tif"][IPress,Texture:Export]

    ] //end of Loop

    ]/*End of ZScript*/

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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.
    Attached Files Attached Files

  5. #5
    Senior Member Follow User Gallery
    Join Date
    Aug 2005
    Posts
    401

    Default

    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
    Last edited by coye; 04-05-08 at 06:00 PM.

  6. #6
    Senior Member Follow User Gallery
    Join Date
    Aug 2005
    Posts
    401

    Default

    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

  7. #7
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    You can use:
    [CODE][IKeyPress,13,[IReset,3]][/CODE]
    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.

  8. #8
    Senior Member Follow User Gallery
    Join Date
    Aug 2005
    Posts
    401

    Default

    brilliant, this is working like a dream.

    Thanks again Marcus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •