1. #1
    Senior Member Follow User Gallery
    Join Date
    Nov 2010
    Location
    Sydney, Australia
    Posts
    150

    Default 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!
    Last edited by bakedbeing; 04-24-17 at 02:36 AM. Reason: Clarity

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    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



    ZFileUtils64.zip

    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.

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Nov 2010
    Location
    Sydney, Australia
    Posts
    150

    Default

    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/showthr...=1#post1135481

    Thanks again!

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Great, you're welcome.

    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.../#selectFolder

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •