ZBrushCentral

Question: Can I open an os window for the user to choose a target folder?

Hi guys, I’m writing a plugin to make exporting to Substance easier, and I want the user to be able to choose a destination folder. I’ve looked through the scripting reference, including for FileUtils and I can’t find anything, nor have I found it yet in any Macro source code (stil early in search).

I’m after the regular file dialogue (in windows it would have quick access etc on left, and not be that weird dinky folder tree explorer) and I also need the user to be able to select a folder without typing in a filename or prefix, because the subtools need to be exported with their names as filenames. This is one reason subtool master’s exporter isn’t ideal for the job.

If such a thing doesn’t exist yet:

  1. can ZScript access any old DLL that exposes functions?
  2. Where can I find documentation on how guys create the custom dlls I find in the data folders of ZFileUtils and Dynamesh Master? Perhaps I can ask a coder at work if they can compile a wee dll that pops the dialogue and returns the path?

Thanks everyone!

I’ll add this ChooseFolder function the the ZFileUtils as soon as I’ve done the MacOSX version. Meanwhile, here is a dll for Windows 64 bit only. You use it like this (this assumes the dll is in a folder called MyPluginData):

[IButton,ChooseFolder,“Choose a Folder”,
[VarSet,dllPath,“MyPluginData\ZFileUtils64.dll”]
[VarDef,folderPath,""]
//create memblock to get the path
[If,[MemGetSize,Mem_FolderPath],

[MemCreate,Mem_FolderPath,256,0]

]
[VarSet,err,[FileExecute, [Var,dllPath],ChooseFolder,Mem_FolderPath]]
[If,err,

//[Note,err] //function will return -1 is user cancels dialog

,

//copy path from memblock to variable

[MemReadString,Mem_FolderPath,folderPath,0,1]

[Note,folderPath]//notes don’t display backward slashes

]
[MemDelete,Mem_FolderPath]
]//end button

Answering your other questions:

  1. In general, no, ZBrush likes a particular form for the functions.
  2. If you are interested in writing code yourself then you’ll need knowledge of C++ and how to compile a dll.

Thank your Marcus, you’re so generous! I’ll pop that in now and keep working.

Regarding 2), there are Unity coders at work but I’m pretty sure one or two have a c++ background, it’d be great to get them involved with making artist tools. I found your 2015 post with a dll template, is there anything more recent I’d need to give them?

http://www.zbrushcentral.com/showthread.php?193080-Writing-Dll-files-for-Zbrush&p=1135481&viewfull=1#post1135481

Thanks again!

Great, you’re welcome. :slight_smile:

I’ve updated the zip file above to include Win 32, and also corrected a missing function in the 64 bit version (in case you are using any of the other ZFileUtils functions). The ZFileUtils is described here.

Yes, that template is still good for Windows, and is easily adapted for MacOSX. If you have any questions, let me know.

Edit: Have updated ZFileUtils to include this : http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/#selectFolder