ZBrushCentral

Can I write Zbrush plugins in C#

Hey all

I am quite new to zbrush, and am interested in the scripting.

Can I use dlls compiled from c# using mono in Zbrush.

Perhaps this is a stretch, but it would be gr8 to create a connection with my game engine

I don’t know C# or Mono but don’t see why not. ZBrush can be picky about arguments and return types so the best form to follow (though this example is C++) is this:

float DLL_EXPORT FunctionName(char* aMessage, double aValue, char* aMemoryBlock)
{
    return 1.0f;
}

Have those arguments in the function even if you don’t use them (they don’t all need to be passed in zscript), and make sure DLL_EXPORT is defined appropriately for the compiler to export an un-garbled function name.

I’d always have a return type of float because you can then easily get that in ZBrush (and it avoids some issues):


[IButton,TestDLL,,

[Note,[FileExecute,"MyDynamicLib.dll",FunctionName]]//will show the return value
]

To get a message out of the dll use a memory block created in zscript:


[VarDef,outString,""]
[MemCreate, Test_Output, 256, 0] // Make a global buffer to get the response string.
[FileExecute,"MyDynamicLib.dll", GetMessage, , ,Test_Output]//calls a dll function that copies message to 'Test_Output'
[MemReadString, Test_Output, outString]
[Note,#outString]

(Use this method rather than the ‘optional memory block output’ indicated in the zscript command reference.)

HTH,

Many thanx for the pointers, I will certainly give this try