ZBrushCentral

Headless ZRemesher Automation?

Hi Everyone,

Is there a way to create a headless automation that imports an obj into zbrush then calls zremesher to retopo it with some settings and export that obj back out?

Any help would be really appreciated.

Thanks!

That would be straightforward to do in zscript I think, assuming you’d run the script from within ZBrush. Would you want to select a number of files to process?

Hi Marcus,

Thanks for the reply sorry its been a while. I was able to create the ZScript from recording the commands as a txt file. I wrapped it in [If,1, code ] to run only once. This works well on my windows7 version of ZB 4R7 P3 however in windows10 same version it does an “Abnormal Termination” almost everytime. Any ideas on why this is getting hung up?

Here is the script I am using

[If,1,
[IPress, HIDE]
[IUnPress,Preferences:Lightbox:Open At Launch]
[FileNameSetNext,“C:\Users\Username\Documents\Exports\meshToZremesher.obj”][IPress,Tool:Import]
[IPress,Transform: Edit]
[IPress,Transform:Fit]
[IPress,Tool:Geometry:WeldPoints]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IPress,Transform:>M<]
[ISet,Tool:Geometry:Target Polygons Count,1.2]
[ISet,Tool:Geometry:AdaptiveSize,50]
[ISet,Tool:Geometry:AdaptiveSize,39]
[FileNameSetNext,“C:\Users\Public\Documents/ZBrushData/Temp/objIn.goz”][IPress,Tool:Geometry:ZRemesher]
[FileNameSetNext,“C:\Users\Username\Documents\Exports\zremesherMesh.obj”][FileNameSetNext,“C:\Users\Username\Documents\Exports\zremesherMesh.obj”][IPress,Tool:Export]
[IKeyPress,78,[IPress,CLOSE]]
]/End of ZScript

Thanks for your help

  1. not sure what "[if, 1,… " involve here really, i can’t to help

  2. [ISet,Tool:Geometry:Target Polygons Count,1.2]

you must to protect string that content white space
this is correct but it’s probably more a detail :slight_smile:

[ISet,“Tool:Geometry:Target Polygons Count”,1.2]

  1. the last comment is missing the /, is that normal ?

  2. adaptive Size and fileNameSetNext is set two times

  3. Remesher use the goz format, and treat the file into a special dynamic library before to reimport the mesh into Zbrush

So here my guess is that you need the path of the goz file after the remersher process, which should be that :

[FileNameSetNext,“C:/Users/Public/Documents/ZBrushData/Temp/objOut.goz”]
[IPress,Tool:Export]

  1. [Ipress close] followed by [ikeypress,78] even with 75 doesn’t close Zbrush.

this works
//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,Preferences:Lightbox:Open At Launch]
[FileNameSetNext,“C:\Users\Public\Documents/ZBrushData/Temp/polystarmesh.obj”][IPress,Tool:Import]
[IPress,Transform: Edit]
[IPress,Transform:Fit]
[IPress,Tool:Geometry:WeldPoints]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IPress,Transform:>M<]
[ISet,Tool:Geometry:Target Polygons Count,1.2]
[ISet,Tool:Geometry:AdaptiveSize,39]

[IPress,Tool:Geometry:ZRemesher]

[FileNameSetNext,“C:/Users/Public/Documents/ZBrushData/Temp/objOut.goz”]
[IPress,Tool:Import]

//export
[FileNameSetNext,“C:\Users\Public\Documents/ZBrushData/Temp/polystarmesh2.obj”]
[IPress,Tool:Export]

]

Hi faceless

thanks for the feedback, Im going to give this a try. The reason I was using the [if,1 code] was from this reference from Marcus

http://www.zbrushcentral.com/showthread.php?178861-Question-Can-I-launch-ZBrush-and-have-it-run-a-script-on-startup-from-a-C-app

thats supposed to only let the script run once, I am not using a button I am instead launching zbrush from outside ZB and executing that zscript, thats why I needed it to run only once

[If,1,
[IShowActions,0]
[IConfig,4.73]
[IUnPress,Preferences:Lightbox:Open At Launch]
[FileNameSetNext,“C:\Users\username\Documents\WorkingFolder\meshToTest.obj”][IPress,Tool:Import]
[IPress,Transform: Edit]
[IPress,Transform:Fit]
[IPress,Tool:Geometry:WeldPoints]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IPress,Transform:>M<]
[ISet,Tool:Geometry:Target Polygons Count,1.2]
[ISet,Tool:Geometry:AdaptiveSize,39]
[IPress,Tool:Geometry:ZRemesher]
[FileNameSetNext,“C:/Users/Public/Documents/ZBrushData/Temp/objOut.goz”][IPress,Tool:Import]
[FileNameSetNext,“C:\Users\Public\Documents/ZBrushData/Temp/polystarmesh2.obj”][IPress,Tool:Export]
]

this is still doing Abnormal Termination on Windows10 machine. I took the code you provided and wrapped it in the [if,1, that Marcus had posted in a previous post. I need that since I am running this headless outside of zbrush and need the script to load and run only once per. Also the [IKeyPress,78,[IPress,CLOSE]] closes ZBrush everytime on my Windows 7 Machine with no problem.

Any ideas? Thanks

I’ve no idea why this should crash Windows 10 but you could try commenting out code until you isolate the crash. Also, you don’t need to import the file from ZRemesher - it will do it automatically. I’d also change the file paths so there are only backslashes:

[If,1,
[IConfig,4.73]
[IUnPress,Preferences:Lightbox:Open At Launch]
[FileNameSetNext,“C:\Users\username\Documents\WorkingFolder\meshToTest.obj”][IPress,Tool:Import]
[IPress,Transform: Edit]
[IPress,Transform:Fit]
[IPress,Tool:Geometry:WeldPoints]
[IPress,Transform:Activate Symmetry]
[IPress,Transform:>X<]
[IPress,Transform:>M<]
[ISet,Tool:Geometry:Target Polygons Count,1.2]
[ISet,Tool:Geometry:AdaptiveSize,39]
[IPress,Tool:Geometry:ZRemesher]
[FileNameSetNext,“C:\Users\Public\Documents\ZBrushData\Temp\polystarmesh2.obj”][IPress,Tool:Export]
]

Hi Marcus,

Thanks for the info, I will give this a spin, also how would I change the file paths to contain backslashes only and specify the file name? Or do you mean in the earlier post from the thread where there was front and back slashes (\Public\Documents/ZBrushData/)? sorry if this is a stupid question I just want to make sure.
Thanks!

Yes, I just meant that if you’re hard-coding the paths to not have a mix of forward slashes and backslashes. ZBrush normally doesn’t mind but I’ve no idea if Win 10 behaves differently.

ok great thank you very much for the info, seems to work right now.

I_m trying to make the code working in ZBr8 if anyone is interest or have any suggestion it will be great to share thoughts about that.
G

The key seems in the script batch_process_script_02, but it need to be ported for R8, so I guess I need to wait a bit more :wink: