ZBrushCentral

Zscript Help-Reseting Index Numbers on Nanomesh

Here’s the scenario… I have multiple subtools with multiple nanomesh on each subtool. Most of the Nanomeshes have hide others on them. I’m working on a script to change the colorize to use mesh material for each index of the nanomeshes, which isnt the problem I can create that easily using a macro, what I’m needing is a way to make sure the index is set back to the original index prior to running the script. Also would be nice to be on the same subtool that I was on prior to script.

Thanks for anyone that can help.

To reset the Index you would just need to store the value in a variable before your main code runs and then reset it at the end, something like this:

[VarSet,id,[IGet,Tool:NanoMesh:m.Index]]//store current index
//do stuff
[ISet,Tool:NanoMesh:m.Index,id]

If you are running through all the subtools then you’d need to get/set the value when each subtool is selected.

To store the current subtool and then reset it after looping through them all you can use:

[VarSet,activeSubT,[SubToolGetActiveIndex]]

[Loop,[SubToolGetCount],
[SubToolSelect,counter]
//do stuff
,counter]

[SubToolSelect,activeSubT]

Note that you will need to incorporate your macro code rather than have separate scripts otherwise you will find that some code won’t run.

HTH,

Thanks marcus_civis! Your Always the Best at Helping with Zscripting! You Guys should seriously do a couple Courses in Zclassroom on Zscripting. Call it Zscripting for Dummies like me when it comes to Zscripting lol. I’ll play with those scripts of yours tonight after work and let you know how it works.

BIG THANKS!

Thanks Again Marcus.

Here’s the Code as it stands, still trying to get the Subtool to land where it was prior to script, for the moment I just tell it to go back to the top of the subtool stack.

//ZBRUSH MACRO - Recorded in ZBrush version 4.73
[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ëescí key.”,
[IShowActions,0]
[IConfig,4.73]
[IUnPress,Render:Render Properties:Shadows]
[IUnPress,Render:Render Properties:AOcclusion]
[ISet,Render:Render Properties:3D Posterize,180]
[ISet,Render:Render Properties:3D Shading,0]
[IPress,Transform: Pf]
[IModSet,Transform: Pf,2]
[SubToolSelect, 0]
[IPress,Tool:SubTool:SelectDown]
[Loop,10,
[VarSet,id,[IGet,Tool:NanoMesh:m.Index]]//store current index
[ISet,Tool:NanoMesh:m.Index,0]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
[ISet,Tool:NanoMesh:m.Index,id]
[IPress,Tool:SubTool:SelectDown]
]//end of Loop
[SubToolSelect, 0]
[IPress,Render:BPR RenderPass:Render Best Preview]]

2 more questions can I do a loop within a loop as you can see above I have a lot of repeating code but wasnt sure if I could put loop in there since it was already in the middle of a loop.

Also wanted to create a randomizer for the Random Seed of a Index of a Nanomesh but tried a dozen variations to get it to work but no luck

[ISet,Tool:NanoMesh:m.Random Seed]

Thanks in Advance

I Think I got it. Had to Tinker a bit with the code you suggested, ended up taking the loop and counter out of the Subtool equation, for some reason it just started looping indefinitely. Took it out and it worked fine. Also did a loop within a loop and everything worked out. Almost starting to understand Zscripting, at least the simple things lol.

Here’s the Working Script Now, gonna do some variations of it. Now that i know what I’m Doing lol

//ZBRUSH MACRO - Recorded in ZBrush version 4.73
[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ëescí key.”,
[IShowActions,0]
[IConfig,4.73]
[VarSet,activeSubT,[SubToolGetActiveIndex]]

[IUnPress,Render:Render Properties:Shadows]
[IUnPress,Render:Render Properties:AOcclusion]
[ISet,Render:Render Properties:3D Posterize,180]
[ISet,Render:Render Properties:3D Shading,0]
[IPress,Transform: Pf]
[IModSet,Transform: Pf,2]
[SubToolSelect, 0]
[IPress,Tool:SubTool:SelectDown]
[Loop,10,
[VarSet,id,[IGet,Tool:NanoMesh:m.Index]]//store current index
[ISet,Tool:NanoMesh:m.Index,0]

[Loop,20,

[IPress,Tool:NanoMesh:m.Mesh Material]
[IPress,Tool:NanoMesh:m.>>]
]//end of Loop

[ISet,Tool:NanoMesh:m.Index,id]
[IPress,Tool:SubTool:SelectDown]
]//end of Loop

[SubToolSelect,activeSubT]

[IPress,Render:BPR RenderPass:Render Best Preview]]


Big Thanks Marcus!

Not sure how you managed to get an infinite loop - I didn’t think that was possible using zscript!!! Anyway, as long as you are getting the results you want then all is good! :+1: