ZBrushCentral

Is there any way to make a script that can be applied to a batch of files?

I have made a script that I need to apply to hundreds of .obj files. The script flips an objects polygons, applies a polish and then does a remesh. The script takes a while to execute on each of my large .obj files so doing each file one by one is real tedious. Is there any way to automate the loading and saving of each .obj file in a folder so that I can do them all at once? I am thinking of something like Photoshops batch command. Thanks for any help.

-Joe

You can do it but it involves some zscripting and you will have to use the ZFileUtils dll to get the contents of a folder. Your zscript will then be able to process the files. You can read about how to work with ZFileUtils here:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/

Something to bear in mind is how ZBrush will handle a lot of OBJs. It might be a good idea for your script to delete each mesh after saving it out and moving on to the next. If you do use the SubTool>Delete button you will need to make sure you have dealt with the warning message you get before running your script, otherwise you could get back from doing something else to find the warning message waiting for you!

Thanks Marcus,

That page looks scarey. I have done some basic programming in the past so I am familiar with the some of the concepts described on that page but seeing the functions listed I think it would be involved getting a batch process script working. I am going to spend an hour or so looking at the scripting documentation but I am not sure I am up to writing a batch process script.

So I am trying to install the ZFilesUtils and I am having a problem getting Zbrush to find the plugin. I download them from the link on this page: http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/. The attached screen shot shows where I put the files. I ran the test script that is included with the file and I am getting an error message. The portion of the script the lists the path to the plugin is shown at the bottom. Does any one know what might be wrong?

Thanks,
-Joe

That page scares me too ;-). You’re in a sub folder rather than the one the error shows…

OK I think I get it now. I moved the test script into a different folder from the plugins. But the test script sets the path to the plugins relative to itself so zbursh could not find the plugins. The plguins are not loaded by Zbrush until the script tells Zbrush where they are.

Did you record the series of actions you want to perform? That helps a lot. Hope you’re successful. I’ve got a folder full of .obj files kicking around on my PC, this could perhaps be useful, I’m on a Win7 PC.

Yes I have the process I want to preform recorded in a macro so that is done. The problem is getting Zbrush to apply that to each file in a folder. The script called “Listing the Contents of a Folder” could be a good start on making a batch process script. It seems like that script will be able to list the path to each file in a folder. But I am now having the problem that I do not know how to use the path to open a file. I looked through the command reference here: http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/command-reference/#Files_and_Filenames. But I don’t see any commands for import and exporting .obj files. Is that possible? Any help would be appreciated.

Thanks,
-Joe

I’m not a scripting wiz nor a programmer, I dabble. There’s this page> http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/advanced-techniques/
And this page>> http://www.zbrushcentral.com/showthread.php?178861-Question-Can-I-launch-ZBrush-and-have-it-run-a-script-on-startup-from-a-C-app&highlight=Load+obj
Theres also a script to load object files kicking around somewhere here on the forums too.

Thanks Doug,

I think I got it. I was able to find out how to import and export .obj files by recording a macro that did that. That plus the “Launching an Open Files Dialog” example on the ZFileUtils page seems to get me there. It has worked on a small test folder of .obj files.

Thanks,
-Joe

Awesome, glad you made it work :wink: Any chance you’ll share the script file in .txt format?

OK attached is the script. No guarentees on this because its the first time I have tried to do anything with Zscript.

To use it first download the ZFileUtils_2_2 plugins from this link: http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/. I think you can put the files anywhere because Zbrush is going to look for them relative to where script is located.

Edit the batch process script to put in the commands you want to apply. The attached image shows where to put your commands.

You must put the batch process script in the same folder as the “MyPluginData” folder or Zbrush will not be able to find the plugins. The attached image shows where I put the files.

Load the script with the Load command on the Zscript pallet.

Open the Tutorial panel at the bottom of the Zbrush window.

There should be a button called BatchObj. When you click it you will get an open file dialogue box where you can select all the .obj file you want to process. The script will open each selected file in turn, apply the recorded macro actions to it and then save the .obj file. The saved file will over write the original. (So it might be a good idea to run it on a copy of your files and not the originals). I did not have to delete any .obj files as Marcus suggested I do in his first reply. Each imported .obj file seems to just replace the previous one. Also when running the script it stopped at a certain point. It might be that my computer went to sleep while the script was running because it did continue to work once I started using the computer again. Another thing to note is that in my script I used Zremesher to reduce the polygon count of my objects. I would have rather used Decimation Master but when I recorded that in a macro I could not get it to play back properly.

Again thanks to Marcus for providing the ZFileUtils plugins and examples.

batch_proc_instructions.jpg
batch_process_script_02.txt (5.1 KB)

Cool, now to make it save the copy to a different folder instead of overwriting the original.

I’m using windows 7 64bit

I’m getting this error. Any help would be great!

Attachments

problem.jpg

doakey3,

The script won’t work for 64 bit ZBrush without updating.

Apologies for resurrecting an old thread :slight_smile:

I was wondering if there is a limit on how many .objs Zbrush can process at a time? I was able to re-purpose Joe’s script (into 4R7 64bit), but for some reason I can’t batch process a whole folder. Selecting over 1000 objs results in the message “0 files selected”. I can process anywhere from 125-500 depending on the length of the name of the file.

Any help is greatly appreciated!

I was able to find out how to import and export .obj files by recording a macro that did that. Where?