here are some simple examples for zscripting in ZBrush. going from writing a method/function to some examples with importing an obj. the biggest take away is that we can use the record button in the zscript menu to record actions in ZBrush which could be later added to a script. i'm still a beginner in zscripting but hope some of these tips are helpful. each example can be saved in a text file (fileName.txt) and it can be loaded in Zbrush using zscript tab.
[RoutineDef, helloFun, // [Note,"Yeeaaay a method !!!"] ] [IButton, callFun, "press button", //call method [RoutineCall, helloFun] ]example 2
//example of a method that takes a single argument [RoutineDef, helloFun, //main part of method [Note, msg] //argument to method ,msg ] [IButton, callFun, "press single input button", //call method [VarSet, msg, "yaay a new message"] [RoutineCall, helloFun, msg] ] //another example of a method that outputs two strings joined together [RoutineDef, helloFunMulti, //main part of method //concactinate two strings to build message [VarSet, msg, [StrMerge, msgA, msgB]] [Note, msg] //argument to method ,msgA, msgB ] [IButton, callFunMultiInput, "press multi input button", //call method [VarSet, msgA, "A message"] [VarSet, msgB, "B message"] [RoutineCall, helloFunMulti, msgA, msgB] ]example 3
[RoutineDef, importObjFun, //main part of method [Note, filePath] //argument to method [FileNameSetNext, filePath] [IPress, Tool:Import] ,filePath ] [IButton, importObjSimple, "press to import", //call method [VarSet, path, "!:/Users/Nathaniel/Desktop/oop_for_facerig_learning/zbrushScriptingIntro/exampleScenes/test_a.OBJ"] [RoutineCall, importObjFun, path] ]example 4
//hard coded [RoutineDef, setVisOnFunA, // [Note,"Turning on hard coded subtool"] //Subtool:[name of subtool]:[name of property] [IModSet, "Tool:SubTool:PM3D_Cube3D_2", 17] //using hardcoded subtool //1 turns it off. 17 turns it on ] [IButton, visFunA, "press button", //call method [RoutineCall, setVisOnFunA] ] //using selected subtool [RoutineDef, setVisOnFunB, // [Note,"Turning on selected subtool"] //get selected subtool name [VarSet, subtoolName, [IGetTitle, Tool:ItemInfo]] //PM3D_Cube3D_2. //has dot at end need to be removed [VarSet, subtoolName, [StrExtract, subtoolName,0, [StrLength, subtoolName]-2 ] ]//end subtoolName construction [VarSet, toolPath, [StrMerge, "Tool:SubTool:", subtoolName]] //ex: "Tool:SubTool:PM3D_Cube3D_2" //[Note, toolPath] [IModSet, toolPath, 17] //17 turns it on //got number by recording zscript actions ] [IButton, visFunB, "press button", //call method [RoutineCall, setVisOnFunB] ]example 5
[RoutineDef, createLayerSimpleFun, //main part of method //argument to method [IPress, Tool:Layers:New] [VarSet, layerName, [IGetTitle,"Tool:Layers:Layer Intensity", 0] ] //print currently selected layer name [Note, layerName] ] [IButton, createLayerSimple, "press to create blendshape layer", //call method [RoutineCall, createLayerSimpleFun] [RoutineCall, createLayerSimpleFun] ]Thanks for looking