Home Technical Talk

[SOLVED] ZBrush, Bake all layers from all Subtools

polycounter lvl 5
Offline / Send Message
goekbenjamin polycounter lvl 5
Hey!
When i am done with modeling, i want to prepare some stuff for exporting the mesh.

Current workflow:

1. set all subtools to highest subdivision
  • Subtools -> all high
2. now, to decimate in the 3. step, i need to make sure all subtools has baked layers
  • select the first subtool
  • "Layers -> "Bake all"
  • arrow down (to select the next subtool)
  • "Layers -> "Bake all"
  • repeat that previous 2 steps until all subtools has baked layers
3. Decimation Master: "preprocess all" then "decimate all"
4. "polypaint from polygroups" (for Substance Painter)
  • select the first subtool
  • Polypaint: "polypaint from polygroups"
  • arrow down (to select the next subtool)
  • Polypaint: "polypaint from polygroups"
  • repeat that previous 2 steps until all subtools has baked layers
5. export visible as fbx
-------------------------------------

You see step 2 and 4 is repetive....
Is there a way to make this steps less repetive? (does ZScript make sense here?)

Replies

  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    Finally after hours and hours of scripting i managed it myself via ZScript
  • MadMike
    Options
    Offline / Send Message
    MadMike polycounter lvl 8
    Hey, is there any chance you would be willing to share this script?
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    MadMike said:
    Hey, is there any chance you would be willing to share this script?
    Sure thing!
    Rewrite it for your own needs, i hope it helps others too!

    What it does is:
    - set all VISIBLE subtools to highest subdivision lvl
    - bake all layers per subtool
    - polypaint from polygroup
    -message out how many subtools affected
    p.s.: i decided that decimation must be done by hand per subtool...so i did not integrated it

    have fun:




    //ZPlugin interface example
    //***********************************************************************************************

    [IShowActions,0]//hides interface actions from user

    //create new subpalette in ZPlugin
    [ISubPalette,"ZPlugin:Workflow"]


    //VARIABLES
    [VarDef, ChangedSubtools,0]
    [VarDef, HiddenSubtools,0]


    //ROUTINES

    [RoutineDef,CheckSubTools,
    //check that we have a subtool
    [If,[IExists,Tool:SubTool:Select Down],
    //do nothing - all OK
    ,//else not a subtool
    //[Note, "No Subtools available"]
    [Exit]
    ]
    ]//end of routine CheckSubTools


    //BUTTON: PREPARE FOR EXPORT

    [IButton, 
    "ZPlugin:Workflow:Prepare for export",
    "Check Visibility of All subtools",
    [If,[MessageOkCancel, "This is not an undoable operation, continue?"] == 0, [EXIT]]
    [RoutineCall,CheckSubTools]
    //SET ALL SUBDIVISIONS TO HIGH
    [IPress, Tool:SubTool:All High]

    //loop through all subtools
    [Loop,[SubToolGetCount],[SubToolSelect,[Val,n]]
    //check visibility
    [If,([IModGet,"Tool:Subtool 0"]&32 == 32),
    //[Note, [IGetTitle,Tool:ItemInfo]]
    //BAKE ALL LAYERS FOR THIS SUBTOOL
    [IPress, Tool:Layers:Bake All]
    //POLYPAINT FROM POLYGROUP
    [IPress, Tool:Polypaint:Polypaint From Polygroups]
    [VarSet,ChangedSubtools, [Var,ChangedSubtools] + 1]
    , //else
    [VarSet,HiddenSubtools, [Var,HiddenSubtools] + 1]
    ]
    ,n]//end loop
    [Note, [StrMerge, [Var, ChangedSubtools], " Subtools prepared (", [Var, HiddenSubtools], " hidden Subtools)"]]
    ]//end button

  • MadMike
    Options
    Offline / Send Message
    MadMike polycounter lvl 8
    Thank you very much, it works great!
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    MadMike said:
    Thank you very much, it works great!
    Glad i could help
  • papagersi
    Options
    Offline / Send Message
    papagersi polycounter lvl 16
    MadMike said:
    Thank you very much, it works great!
    How to Use this?!  I'm very new for Script like this  :s
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    papagersi said:
    MadMike said:
    Thank you very much, it works great!
    How to Use this?!  I'm very new for Script like this  :s
    Hey there!
    Just create a txt and copy-paste the code above!
    Then in zbrush, you go:
    - zscript -> load (load the txt file)
    after that, it should be a new menu in zplugin called "Workflow" with a button inside

    Tadaa :D
  • Cuvey
    Options
    Offline / Send Message
    Cuvey polycounter lvl 6
    goekbenjamin  Huge thanks for the script!  I put that button on my UI to keep it handy at all times, but it goes away every time I open Zbrush, and I have to load the script again. Is there any way to fix that?
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    Cuvey said:
    goekbenjamin  Huge thanks for the script!  I put that button on my UI to keep it handy at all times, but it goes away every time I open Zbrush, and I have to load the script again. Is there any way to fix that?
    No problem :)

    Sure, just save your UI, that should work i think:


  • Cuvey
    Options
    Offline / Send Message
    Cuvey polycounter lvl 6
    Sadly this doesn't work :( Not even if I put the script in the Zstartup/Zscripts folder, which I was hopeful would work
  • cryrid
    Options
    Offline / Send Message
    cryrid interpolator
    When you load a .txt file script, zbrush will compile it into a .zsc file. Put that in your \ZStartup\ZPlugs64 directory. 
  • CodeFather
    Options
    Offline / Send Message
    CodeFather polycounter lvl 15
    You can also use the Zrepeat It plugin (download from here) , it comes with few scripts one of which is Bake All Layers.  You can specify to be applied to All, Visible or Selected only subtools. 
  • Cuvey
    Options
    Offline / Send Message
    Cuvey polycounter lvl 6
    cryrid said:
    When you load a .txt file script, zbrush will compile it into a .zsc file. Put that in your \ZStartup\ZPlugs64 directory. 
    You can also use the Zrepeat It plugin (download from here) , it comes with few scripts one of which is Bake All Layers.  You can specify to be applied to All, Visible or Selected only subtools. 
    Thank you both! These solutions work. And in case someone else needs this function and can't make it work, now it comes as part of the Clean Tool Master plugin
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    Cuvey said:
    cryrid said:
    When you load a .txt file script, zbrush will compile it into a .zsc file. Put that in your \ZStartup\ZPlugs64 directory. 
    You can also use the Zrepeat It plugin (download from here) , it comes with few scripts one of which is Bake All Layers.  You can specify to be applied to All, Visible or Selected only subtools. 
    Thank you both! These solutions work. And in case someone else needs this function and can't make it work, now it comes as part of the Clean Tool Master plugin
    Great! Thank you for that! :)
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    Hey there,
    i extended the script, now you can:

    - Bake all layer from all visible subtools (as before)
    - Stop all recordings from all subtools (New)

    i had the weird bug/problem my subtools turns black sometimes when layers a recording and i bake them down.

    I hope this helps someone too
  • pasha_sevez
    Options
    Offline / Send Message
    pasha_sevez polycounter lvl 13
    @goekbenjamin Hey Ben, I was wondering if it's possible to adjust your script to work with the sub-tool groups, right now only the non-grouped sub-tools get processed by it. Overall it works great, but this little caveat breaks the experience a bit.
  • goekbenjamin
    Options
    Offline / Send Message
    goekbenjamin polycounter lvl 5
    @goekbenjamin Hey Ben, I was wondering if it's possible to adjust your script to work with the sub-tool groups, right now only the non-grouped sub-tools get processed by it. Overall it works great, but this little caveat breaks the experience a bit.
    Hi, i made this script where groups did not existed in zbrush :)

    Currently i am not at home but you can of course change the script as if you wish.

    I made tze script while checking the available reference here:

    http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/command-reference/
  • pasha_sevez
    Options
    Offline / Send Message
    pasha_sevez polycounter lvl 13
    Thanks for pointing out! I will check it myself, but once you get an opportunity to add this feature on your side, it would be great too (never dealt with ZScript, will see how it will come out ^^ )! Anyway thanks!
Sign In or Register to comment.