Skip to content

Instantly share code, notes, and snippets.

@uranio-235
Last active February 24, 2023 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uranio-235/e8b528e05b8ad942ffa5d1c876f389a1 to your computer and use it in GitHub Desktop.
Save uranio-235/e8b528e05b8ad942ffa5d1c876f389a1 to your computer and use it in GitHub Desktop.
Zscripts para ZBrush, Cubanoaqui twitter
[IButton, GrowVisiblePolygroups, "Grow Visible Polygroups Once and Regroup", // Get the active document and initialize some variables [VarSet, doc, IGet, "ZBrush Document"],
[VarSet, pgCount, 0],
// Get the number of visible polygroups
[If, [IGet, "Tool:SubTool:Visible"] > 1,
[Loop, [IGet, "Tool:Polygroups Grp"],
[If, [IGet, "Tool:Polygroups:" + pgCount + ":Visible"],
// Grow the visibility of the current polygroup
[IPress, "Tool:Polygroups:Group Visible"],
[IPress, "Tool:Polygroups:Group Visible"],
// Regroup the polygroups
[IPress, "Tool:Polygroups:Auto Groups"],
// Update the number of visible polygroups
[VarSet, pgCount, [IGet, "Tool:Polygroups Grp"]],
,
// If the current polygroup is not visible, skip it
[VarSet, pgCount, [IGet, "Tool:Polygroups Grp"]],
]
],
,
// If there are no visible polygroups, display a message
[Note, "There are no visible polygroups."],
]
]
@nilsandrey
Copy link

nilsandrey commented Feb 24, 2023

Variante con bing chat:

Copiado markdown ;)

ZScript is ZBrush's built-in scripting language that can automate common or repetitive tasks¹. To create a ZScript for your task, you need to use commands that can manipulate polygroups and visibility⁶⁷⁸⁹.

Some possible commands are:

  • PolyGroupVisible - assigns a new polygroup to visible polygons
  • ShowPt - shows or hides points based on a mask
  • Visibility - controls visibility of subtools
  • IsPolyGroupVisible - returns 1 if a polygroup is visible, 0 otherwise

A sample ZScript for your task could look something like this:

[VarDef,polyCount,[IGetMax,Polygroups:Group Total]] //get number of polygroups
[Loop,polyCount,
  [VarSet,i,[Val,n]] //loop index
  [Loop,polyCount,
    [If,i==[Val,m], //if current polygroup matches loop index
      [PolyGroupVisible,[Val,m],1] //show it
      , 
      [PolyGroupVisible,[Val,m],0] //hide it
    ]
    ,m,,1 //loop variable m from 1 to polyCount
  ]
  [ShowPt,2] //grow visibility once
  [PolyGroupVisible,-1,-2] //regroup visible polygons with new ID
]
[ShowPt,0] //show all polygons

I hope this helps. Do you have any questions? 😊

Source: Conversation with Bing, 2/23/2023(1) ZScripting | ZBrush Docs - Pixologic. http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/ Accessed 2/23/2023.
(2) Assigning Polygroups in Zbrush | Create 3D Art. https://create3dart.com/how-to-create-polygroups-in-zbrush/ Accessed 2/23/2023.
(3) Mesh Visibility | ZBrush Docs - Pixologic. http://docs.pixologic.com/user-guide/3d-modeling/modeling-basics/mesh-visibility/ Accessed 2/23/2023.
(4) Polygroups | ZBrush Docs - Pixologic. http://docs.pixologic.com/reference-guide/tool/polymesh/polygroups/ Accessed 2/23/2023.
(5) Polygroups | ZBrush Docs - Pixologic. http://docs.pixologic.com/user-guide/3d-modeling/modeling-basics/polygroups/ Accessed 2/23/2023.
(6) Zscript | ZBrush Docs - Pixologic. http://docs.pixologic.com/reference-guide/zscript/ Accessed 2/23/2023.
(7) Getting Started | ZBrush Docs - Pixologic. http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/getting-started/ Accessed 2/23/2023.
(8) Sample ZScripts | ZBrush Docs - Pixologic. http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/sample-zscripts/ Accessed 2/23/2023.
(9) . https://bing.com/search?q=ZBrush+polygroup+visibility Accessed 2/23/2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment