ZBrushCentral

ZFileUtils in 2022

Is ZFileUtils still working in 2022? I keep trying to use it but it throws me different errors every time. This time it said that the item in the list is empty and i dont really know how to get it to work properly. Can anyone help me with setting up the link to the dll and accessing the functions?

I found the example codes on the Zscript page, but with that ‘setting up the dll path’ code example, it broke my plugin somehow.

Hi Rob,

Welcome to ZBC! :slight_smile:

The ZFileUtils works fine in 2022. It’s difficult to tell what might be the problem without seeing the code but if you’d like to post the code, or send it to me, then I’ll take a look. Use private message if you’d prefer.

Marcus

Hi Marcus,

Thank you! I have been browsing this forum for a while and have seen you are the one that can answer all questions.

Unfortunately, im not allowed to share any of the code as i am under NDA. If i can just get the functions working in a separate script, then im sure with my technical skills i can extrapolate the right approach for my NDA script.

Basically, what i did was the following:

  • I copied and pasted the ‘setting up the dll’ code into a new script.
  • I tested it out
  • It gave me the error
    image

This is my new not NDA code:

[RoutineDef, CheckSystem,
//check ZBrush version
[VarSet,Zvers,[ZBrushInfo,0]]
[If,[Val,Zvers] >= 2021.0,
[Note,"\Cff9923This zscript\Cffffff is not designed for this version of
\Cff9923ZBrush\Cffffff.",3,4737096,300]
[Exit]
]
[VarSet,isMac, [ZBrushInfo,6]] //check Mac or PC
// Make sure we have the dll and set its path
[If,[ZBrushInfo,16]==64,//64 bit
[If,isMac,
//use the path below for testing only
[VarSet,dllPath,“MyPluginData/ZFileUtils.lib”]
//use the path below for installed plugins
//[VarSet,dllPath,“ZBRUSH_ZSTARTUP/ZPlugs64/MyPluginData/ZFileUtils.lib”]
,
//use the path below for testing only
[VarSet,dllPath,“MyPluginData\ZFileUtils64.dll”]
//use the path below for installed plugins
//[VarSet,dllPath,“ZBRUSH_ZSTARTUP\ZPlugs64\MyPluginData\ZFileUtils64.dll”]
]
,//else 32 bit - no longer supported
[Note,"\Cff9923This zscript\Cffffff is not designed for this version of
\Cff9923ZBrush\Cffffff.",3,4737096,300]
[Exit]
]
[If, [FileExists, [Var,dllPath]],
//check that correct version
[VarSet, dllVersion, [FileExecute, [Var,dllPath], Version]]
[If, [Val,dllVersion] >= 8.0,//dll version
//OK
,//else earlier version
[Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 is
an earlier version which does not support this plugin. Please install correct version."]
[Exit]
]
, // else no DLL.
[Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 could
not be found at the correct location. Please re-install the plugin, making sure the
relevant files and folders are in the \CffffffZStartup/ZPlugs\Cc0c0c0 folder."]
[Exit]
]
]//end routine

[IButton,SubtoolRename,“Rename selected subtool”,
[RoutineCall, CheckSystem]
[Note, “0”]
[VarSet,newName,“My New Name”]
[VarSet,buttonPath,“Tool:SubTool:Rename”]
//set buttonPath to the button you want
//“Tool:SubTool:Rename” - for SubTool
//“Tool:Layers:Rename” - for Layers
//“Preferences:Transpose Units:Set Units” - for Transpose Units
[If, (([IExists, buttonPath]) && ([IsEnabled, buttonPath])),
[FileExecute, [Var, dllPath], RenameSetNext, newName]
[IPress, buttonPath]
[Note, “1”]
]
]//end button

its basically just the samples of website strung totgether :slight_smile:

Hi Rob,

The error you are getting is just because the variable “dllPath” has not been declared as a global variable. This means that the code in the button can’t access it, even though it has been defined in the “CheckSystem” routine.

All you need to do is put
[VarDef, dllPath, ""]
at the top of your script (outside any routines or buttons).

There’s a working example zscript included with the latest ZFileUtils here, which you may find useful:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/zfileutils/

HTH,
Marcus

1 Like

Hi Marcus,

Thanks for the quick relpy :slight_smile:

I had a feeling it was something as simple as this. That seems to do the trick.

Thank you !

1 Like

you can use the markdown code tag to display some code on the forum as

```
// your code here
```

hope his helps
Nicolas

1 Like