Chapter 11. ZScripts, Macros, and Interface Customization

ZScripts, Macros, and Interface Customization

ZBrush gives you a wide array of customization and scripting options. In this chapter we'll look at ZBrush interface building as well as ZScripts and macros. ZScripting is the built-in ZBrush scripting language, and using it requires some knowledge of programming. Macros are recordings of ZBrush actions saved as brushes and require no scripting skill. Macros can be a huge time-saver when you're creating custom brushes or menu options.

ZScripts, Macros, and Interface Customization

Contrasting ZScripts and Macros

ZScripts are programs, written in a ZBrush scripting language, that allow the user to automate tasks inside of ZBrush. ZScripting is a macro-based programming language. You write a ZScript and it is interpreted by the program as it runs. Both are freely distributed via ZBrushCentral, and the user community is overflowing with great ZScripts.

Contrasting ZScripts and Macros

Note

Installing a ZScript is as simple as copying a file into a folder. For example, we'll use the incredibly useful AutoSave plug-in by ZBrushCentral member Svengali, which is included on the DVD. When you download a ZScript from the Internet, it will most often come in a ZIP archive. Extracting the archive will provide you with a single .zsc file or in some cases a data folder and a .zsc file. In the case of AutoSave, you will have a single .zsc file.

To install this ZScript, copy the file. You want to paste it into your ZBrush installation directory: /zbrush3/zstartup/zplugs. ZScripts copied into this folder will install automatically when ZBrush starts (Figure 11.1). Copy the AutoSave script to this location now. If ZBrush is running, close it and reopen the program now.

When ZBrush loads, you will have a new folder under the ZPlugin menu called Svengali. In the ZPlugin menu you will find several buttons (Figure 11.2). These buttons allow you to save a numbered iteration of a ZBrush document, ZTool, ZMovie, or a screen capture. This makes saving iterations of your model a simple one-button click.

Contrasting ZScripts and Macros
ZStartup folder

Figure 11.1. ZStartup folder

The Svengali menu

Figure 11.2. The Svengali menu

To use the program, load a ZTool and in the ZPlugin Svengali menu click the Model button. This will save the first iteration of the ZTool setting, the filename, and the starting number. In this case, the model name is _001.

Now when you click the m+ button, a new ZTool will save to the same folder with a new three-digit extension—in this case, _002. This ensures you save new copies of the file each time; if a file becomes corrupted, you won't lose your work (Figure 11.3).

Iterated file list

Figure 11.3. Iterated file list

These buttons can be easily docked to new locations in the interface or even assigned hotkeys. Later in this chapter we'll do just that while creating a custom interface.

Recording Macros

ZScripts are not limited to only those who can write programming languages. For repetitive tasks, ZBrush comes with a macro recorder. Macros are recordings of ZBrush actions stored as buttons. They can be used to store custom brush setups, and to perform common actions such as creating a polymesh sphere and preparing it for sculpting, or even loading a selection of tools or alphas. In this exercise, you will create a button to load a polysphere and prepare it for sculpting:

  1. To record a macro, begin by clicking the New Macro button under the Macro menu (Figure 11.4). Any actions you perform in ZBrush after clicking this button will be recorded in the new macro until you click the End Macro button.

    Recording a macro

    Figure 11.4. Recording a macro

  2. Click in the Tool menu and select the sphere3D tool. Click MakePolymesh3d and draw the sphere on the canvas. Orient the poles to the top and bottom of the sphere and turn on X Symmetry.

  3. Return to the Macro menu and click the End Macro button. ZBrush will prompt you for a place to store the macro. Save it in the ZStartup/macros folder (Figure 11.5). Macros stored here will load with ZBrush at startup. The subfolder in which you save the macro will determine the heading under which it appears in ZBrush. I've saved this macro in the misc folder with the name createSphere.

  4. Under Macros, click Reload All Macros. This will reinstall all macros in the ZStartup/Macros folder. Under the Macro menu in the misc selections, you will now find the createSphere macro button (Figure 11.6). Click this and the actions will replay, creating a sphere and preparing it for sculpting. It is possible to take this button and dock it elsewhere in the interface. We'll discuss interface customization later in this chapter.

The Macros folder

Figure 11.5. The Macros folder

The createSphere macro button

Figure 11.6. The createSphere macro button

Now that you have created a macro for generating a polymesh sphere, let's try a different application of macros. Next you'll create a custom macro brush.

  1. Click New Macro under the Macro menu. ZBrush is now recording.

  2. From the Brush menu, select the Simple brush.

  3. From the Stroke menu, select Spray. Turn the Color modifier down to 0.

  4. From the Alpha menu, select Alpha 07.

  5. Select the RGB red and turn off all modifiers on the brush but RGB.

  6. End recording and save this macro under the macro brushes menu. Call it Spatterbrush.

You have now created a custom macro brush that mimics the spray brush from earlier in this book. By storing the brush setup in a macro, you can alter settings such as the RGB value, stroke settings, and even masking settings.

You can assign this brush a hotkey or dock the button elsewhere in the interface. When using macro brushes, it is always a good idea to create a new macro to return the brush to its default setting. To do this for the Spatterbrush, follow these steps:

The standardBrush macro button

Figure 11.7. The standardBrush macro button

  1. Click New Macro to begin recording.

  2. Select the Simple brush. Change Alpha back to off and the Stroke to Freehand.

  3. Turn off RGB and turn on ZAdd.

  4. In the Macro menu, click EndMacro. Save this macro in the Macros/Brushes folder as standardBrush.

  5. In the Macros menu, click Reload All Macros. This will load the button under Macros/Brushes for the Standard brush (Figure 11.7). Now when you select the Spatterbrush and want to switch back to the Standard brush, click this button. Otherwise, the Standard brush will retain the previous settings.

Anatomy of a ZScript

This section was contributed by featured artist Svengali.

Many ZBrushers use ZScripting as a simple recorder to capture all mouse moves, mouse clicks, and keyboard presses made while modeling. When the ZScript recording is stopped, it is saved to a text file. When reloaded for playback, the ZScript will faithfully reproduce the entire recorded modeling session. What a powerful teaching tool! Of course, a ZScript file created this way may also be viewed in a text editor to show how many ZScripting commands work.

But a ZScript can be much more. You can write original ZScripts that provide a way to do the following:

  • Customize ZBrush with new buttons.

  • Enhance ZBrush with new functionality.

  • Automate and streamline tedious ZBrush processes.

  • See into ZBrush's inner workings.

We'll examine the power of ZScripting by looking inside a sophisticated, practical script called ModelViews that presents a pop-up menu with buttons for saving and loading four, posed views of our model. ModelViews will teach us the purpose and advantage of subroutines and how easily we can create an autoloading ZBrush plug-in.

ZScripting Fundamentals

There are three main sections in any ZScript, simple or complex:

Variables

Define and assign values to the global variables we'll use in the script.

Subroutines

Name each of the subroutines and script their functionality.

Buttons

The Main section is where we define the buttons and how they work.

You should also refer to the indispensable ZScript Command Reference (which can be found in the ZBrush Wiki at http://www.zbrush.info) for a more complete explanation of usage, syntax, and arguments. Here are some basic ZScript conventions and commands:

Comments

Wherever authors of a script want to include information for users who are reading their script, they'll insert a comment by first typing // (double forward slashes), followed by informative details. ZBrush knows to ignore these comments when running the script.

Bracket pairs

Every command must be enclosed in brackets ([]) so ZBrush will recognize the command or commands to process. Missing brackets can be hard to track down and will likely cause the script to abort, so be careful!

VarDef

Before a variable can be used, it must be created and assigned a unique name. Along with naming it, the variable will be assigned a value (numeric) or text (called a string and enclosed in quotation marks).

VarSet

Once a variable is defined, the script will use VarSet to assign a new value (or string) to the variable.

RoutineDef

Subroutines are mini-scripts that are included in the larger script. Each is designed to do one job and is "called" each time that job needs to be done. Subroutines make it easy to organize your script. In fact, once you've designed and tested a subroutine, you can cut and paste it into other scripts, thus saving time and effort.

RoutineCall

Once a subroutine is defined, you simply insert a RoutineCall command anywhere else in the script and the task gets done. When the called subroutine has finished, it returns to the command line following the RoutineCall and continues with the script.

IGet

This versatile command lets ZScript test the status of various ZBrush buttons, sliders, and internal settings, such as reading canvas dimensions or detecting whether or not a certain button is clicked. You will use this command frequently in most of the ZScripts you write.

TransformGet

This useful command retrieves the transformation values from the current model: X, Y, and Z values for position, for size, and for rotation angle. It takes nine separate variables to capture and store this information.

TransformSet

This companion command applies new transformation values to the model, thus posing a new view of it on the ZBrush canvas.

Note

This command sends a pop-up message to communicate with the user. (Later we'll find out a pop-up note may also include buttons that the user can click.)

Two final commands involve script flow control: the If command (used for testing/branching) and the Loop command (used to repeat the same group of commands a designated number of times):

If

Tests whether a statement is True or False by comparing a known value with the contents of a variable or some internal ZBrush state or value. Then, depending on the answer, ZBrush chooses to execute one of two different sets of commands. Here's an example:

[If, A == 1,  // tests the value of A
   [VarSet, B, 10 ] // A does equal 1, set B to ten
, // else   // Otherwise...
   [VarSet, B, 20 ] // A not equal 1, Set B to twenty
]
Loop

This powerful command lets ZBrush execute the same list of commands a specified number of times. Loops (shown here) will be used several times in our second ZScript:

[Loop, 5,
   [VarSet, A, A + 10 ] // add ten to A for each loop
]

Before we move on to our script, let's look at two advanced groups of ZScript commands to see what they do.

The first group contains commands that use a memory block where variables can be safely stored. Normally, when you exit a ZScript, any values stored in script variables are lost. The next time you start the ZScript, the variables will all restart with their original values. With these memory commands, all variable values can be copied into protected memory (and from there, copied to a disk file) so they can be used again later in the modeling session or even on another day.

Managing Memory Blocks

The ZScript language provides several commands that define a memory block and refer to it using a unique name. Other commands read or write values to the memory block and will even save a copy of the memory block to a disk file.

MemCreate

Creates the memory block (MemBlock) by assigning it a name and defining its size, which is always some multiple of four. For example, a MemBlock to hold 10 variables would be 4×10, or 40 bytes.

MemDelete

As you would think, this command deletes the named memory block.

MemCreateFromFile

This command creates a memory block too, but it then immediately loads the MemBlock with the contents of the named file, setting the block size based on the file size.

MemWrite

Writes the value stored in the named variable to a designated position in the memory block. The position must also be some multiple of four since each variable is stored as 4 bytes.

MemRead

Reads a value stored in the MemBlock into a named variable. Again, the position of the value is a multiple of 4-byte offsets into the memory block.

MTransformGet

This powerful command carries out several steps when called. It reads the XYZ for position, XYZ for scale, and XYZ for rotation for the current model; then, without any other instructions, it automatically writes those nine values directly into the MemBlock at the designated offset. It's like the TransformGet command on steroids!

MTransformSet

Likewise, this companion command carries out several steps as well when called. It looks into the named MemBlock at the offset designated, for nine variables (36 bytes). It then loads those values representing XYZ for position, XYZ for scale, and XYZ for rotation and uses these values to pose the active model on the canvas.

Making a ZScript into a Plug-In

Finally, let's take a quick look at the command that makes a script into a plug-in and how it would be used to create a button. A plug-in is a special ZScript that defines one or more button sets that are loaded automatically when ZBrush starts up. Most often these scripted buttons end up in a submenu of the ZPlugin menu.

ISubPalette

This command is added at the beginning of the Main Script section before the IButton of the plug-in is defined. It designates for ZBrush a path to the Palette menu where the plug-in's button should be placed.

IButton

Notice in the ModelViews script how the IButton is named: We must remember to include the path defined in the ISubPalette command as part of the IButton's name. Thus the name becomes ZPlugin:MyPlugin:ModelViews, which places the button in the MyPlugin subpalette group. (A subpalette in ZBrush is essentially just a submenu. It is any menu heading that can be unrolled when clicked and contains other buttons.)

Anatomy of ModelViews, a Pop-Up Menu ZScript

Note

In this ZScript, which is available on the companion DVD, we'll create a simple but useful little utility. While editing a model, assume we want to store and retrieve up to four views of it as we work. One easy way is to create a ZScript pop-up note that displays a menu like the one in Figure 11.8.

The logic of the ZScript is indicated in the flowchart in Figure 11.9. Only buttons for View 1 and Save 1 are included since the other three pairs work exactly the same way. Compare the flow of the diagram to the ModelViews script to see how the concept is turned into buttons and subroutines.

When we click the ModelViews plug-in button, it displays a pop-up menu note consisting of the menu title, four Save buttons, four View buttons, and an Exit button. Each time we click any one of the four Save buttons, data from the current pose of our model is stored into block memory (which is also saved to a disk file).

The pop-up box that will display from our script

Figure 11.8. The pop-up box that will display from our script

After that, each time we click the matching View button, the data is retrieved from block memory and the model is re-posed to the exact same view that was saved. To leave the menu, we click the Exit button and continue modeling.

An innovation for this menu project is the presence of a hidden button, right behind the menu title. Clicking on the title will display another pop-up note, which peeks at the data stored for our four model views in block memory. Another click brings back the menu.

Code flow for the ModelViews script

Figure 11.9. Code flow for the ModelViews script

In the following section, we'll forgo a line-by-line analysis as we deconstruct the ZScript called ModelViews. Instead we'll focus on the various subroutines that set up and manage menu operations.

Subroutines and What They Do

Each subroutine is designed to perform one operation. Look at the subroutine name to see the task it is doing, then follow along in the ZScript listing to see how it does what it does.

Note

Some subroutines make calls to other subroutines to complete their own task. This division of labor is essential to writing efficient ZScripts.

Test3d subroutine

Tests for active model, and does it in several ways. First it checks whether the Edit button is clicked, indicating that the model is in Edit mode. But there are other things we also need to check to see if a model is active. Any of the Transformation buttons (Move, Scale, or Rotate) may be clicked while the user adjusts the model with the Gizmo.

If the Test3d routine discovers no model in Edit or Gizmo mode, it displays a pop-up warning note for two seconds and then exits the script. Otherwise, the routine returns and the script continues.

LoadViews subroutine

First it tests if the disk file named ModelViews.DAT exists. Why? Because the very first time this script runs, the disk file won't exist and it must be created by a call to another subroutine called ResetViews (described in a moment), which creates the ViewMemBlock of memory, loads it with default data, and saves it to a disk file.

Now, and every time this routine is called in the future, it will deliberately delete the block memory so it can re-create it using the MemCreateFromFile command, which loads in the data from the ModelViews.DAT file of the last saved views.

SaveViews subroutine

Does what it says: saves the ViewMemBlock of memory to the ModelViews.DAT disk file.

ResetViews subroutine

Creates a block of memory of 144 bytes and names it ViewMemBlock, a unique name only used by the ModelViews ZScript. Once created, this empty memory block needs to be filled with four "default" views, which will all be the same home view: your model centered in screen and facing front. A simple loop command is used to load in the four sets of data, one byte at a time. Look at the ModelViews script listing to see how it does this and look at the diagram (Figure 11.10), which visualizes the ViewMemBlock layout highlighting the nine data values for the first View. Finally, with a routine call to Save Views, the contents of ViewMemBlock are copied to the disk file.

Memory block layout

Figure 11.10. Memory block layout

ShowMenu subroutine

At first glance, this subroutine can be a little overwhelming, but it really is simple and consists of three parts. The first part is dedicated to the appearance of the menu; in the other two parts, a loop is created to allow users to stay inside the menu until they click Exit.

Part One

Defines the colors used when drawing the menu and buttons. The color is assigned using the [VarSet, Clr2, 0xc00000 ] command, which works like this. Following the standard hexadecimal prefix 0x (zero x) are six numbers. Each hex number will be between 0 and f in pairs representing red (c0), green (00), blue (00). For more on this 6-digit color concept, look in the ZScript Code Reference under the RGB entry.

Part Two

Inside the loop, this part creates the menu using the NoteIButton command for the note background, and more NoteIButton commands to name and set up each of the buttons displayed on the menu. See the NoteIButton command in the Code Reference for more details on what each of the values designate.

It is important to point to the command line following the last NoteIButton command. It reads:

[VarSet, Reply, [Note, , , ,0 ,0 ,0 ] ]

This forces the note menu to be displayed and waits for the user to click one of the buttons. Once a button is clicked, the number identifying it is stored in the variable named Reply.

Part Three

Consists of a series of If commands that test the value in the Reply variable. Let's look inside a few of these tests to see how the menu works:

  • If the Exit button (10) was clicked, the script simply ends with an Exit command.

  • If the Hidden button (11) was clicked, the script calls the PeekMem subroutine, which displays the contents of the memory in the ViewMemBlock.

  • If one of the View buttons (2), (4), (6), or (8) was clicked, the script loads the ViewMemBlock from the disk file, then poses the model using data stored for one of the four views. If Reply equals (2), it uses the first group of nine values from the ViewMemBlock. Reply (4) will use the second group, and (6) or (8) uses the third or fourth group.

  • If one of the Save buttons (3), (5), (7), or (9) was clicked, the script saves the view by inserting the appropriate nine transform values into the ViewMemBlock. Then the disk file is updated with the contents of the ViewMemBlock.

ShowMem subroutine

When called, this subroutine displays a new pop-up note showing the contents of the ViewMemBlock consisting of the four Transform view groups. The subroutine returns to the menu when the user clicks the left mouse button.

FixRotateY subroutine

This subroutine examines the model's RotateY setting and adds .01 to the value for RotateY, only if RotateY is set to zero. Without this adjustment, the MTransformSet command will mistakenly display the model in home position but upside down.

The ModelViews Button

In this ZScript, only one button is actually created. Note that the commands used to define the ModelViews button consist entirely of routine calls to four of the subroutines we've already examined. In order, these subroutines are: Test3d, LoadViews, FixRotateY, and, of course, ShowMenu.

This economy of commands for our button definition demonstrates the power of subroutines. Remember, these subroutines as designed may be reused in other ZScripts. Follow this approach in your own scripts and you'll quickly evolve an expansive library of subroutines that will streamline the design and writing of all your future ZScripts.

Making ModelViews into a Plug-In

The ISubPalette command in the script is used to identify the menu and subpalette path where the plug-in button (or buttons) will be created.

In our ZScript, the [ISubPalette,ZPlugin:MyPlugin] command names the ZPlugin palette menu and establishes a new subpalette named MyPlugin.

For a plug-in button to work, the subpalette path must always be used as part of the IButton's name.

Note

It's important to save your ZScript as a .txt file in the StartupPlugs folder with all the other custom plug-in scripts. Before you can use the new plug-in there is one last thing left to do. It must be converted into a new file: ModelViews.zsc, a compressed format that removes all the comments from the script and encodes the commands in a form only readable by ZBrush.

Conversion happens automatically the first time you use the Load button in the ZScripts palette menu to run the ModelViews.txt file in the ZStartupPlugs directory. After that, the new ModelViews button will be always be available the ZPlugsMyPlug subpalette.

It is possible to customize your ZBrush interface to make the ModelViews button (or any of the other plug-in buttons) always available. To do so, you must first click the Enable Customize button in the Preferences:CustomUI subpalette. Then, holding down the Ctrl button, drag the ModelViews button from the ZPlugs menu onto an interface shelf area and press Ctrl+Shift+I. Remember to click the Enable Customize button again, and you are done. The custom buttons will appear whenever ZBrush is restarted.

Now ZBrush will always include the new ModelViews button on startup.

Debugging a ZScript

Writing scripts can sometimes be frustrating because the command syntax and script logic must be exactly right. However, ZBrush tries to help you in a number of ways when your ZScript contains errors.

Often a ZScript with syntax errors simply won't run. Sometimes a ZScript will run, but the syntax error is discovered only when a certain button is clicked. In either case ZBrush will pop up an error message with a guess as to the script lines containing the error, though this can be wrong, especially in the case of mismatched brackets.

By scrolling down the script's text displayed in the ZScript window, you will find a point where the formatted color coding stops and the text becomes black. This is the point where the error has likely occurred. Once you discover the error, you must go back into your editor to correct the original ZScript text and resave it. In ZBrush, reload the .txt version again via the ZScript palette menu to test the new version.

Plug-in ZScript errors are a special case, and here is a good tip to remember. You should always restart ZBrush after correcting and resaving a plug-in script you are debugging so a new .zsc version of the script is created and loaded. Each time ZBrush starts up, it regenerates fresh .zsc scripts for all matching .txt files it finds in the ZPlugins folder.

Recommended ZScripting References

For further study, I recommend the ZBrush online wiki, which has an extensive section on ZScripting for beginners and seasoned scripters. In the wiki you can also find the indispensable ZScript Command Reference. Keep that handy; you will use it often.

In fact, ZBrush itself has a built-in lexicon of ZScript commands that can be accessed by clicking the Cmd button in the ZScript palette. This opens a scrollable listing in the ZScript window, just below the canvas.

Finally, in Pixologic's ZBrushCentral Forum, you'll find a very active online ZBrush user community. Look for two forums (the ZBrush ZScripting Help forum and the ZBrush ZScript Utilities forum) where ZScripting questions are quickly answered and free ZScript plug-ins are posted by Pixologic and numerous script writers from the ZBrush user community.

Hotkeys

Any menu item in ZBrush may be assigned a custom hotkey. This is particularly useful for speeding up workflow and allowing you to remain centered on your task at hand rather than removing attention from your work and placing it on the interface.

ZBrush comes with many standard hotkeys already, such as T for Edit mode and F for re-centering the model. There are also some useful function key shortcuts new to ZBrush Pressing the function keys at the top of the screen will bring up the various associated palettes listed in Table 11.1.

Table 11.1. The Default Palette Hotkeys

Key

Palette

F1

Tools

F2

Brush

F3

Stroke

F4

Alpha

F5

Texture

F6

Material

Pressing one of these function keys will instantly bring up the appropriate palette at the location of your cursor. This can be a huge time-saver when you're in the middle of a work session as the time it takes to move through the interface does add up over the course of a day. Other useful hotkeys can be easily found by simply mousing over an interface item. If there is a default key assigned, it will appear in the tooltip. Figure 11.11 shows the hotkey for Subdivide Mesh (Ctrl+D).

The hotkeys for certain buttons can be found by mousing over them and reading the tooltip.

Figure 11.11. The hotkeys for certain buttons can be found by mousing over them and reading the tooltip.

Making Custom Hotkeys

Any interface item can be assigned a custom hotkey by simply holding down the Ctrl key and clicking the button. If another hotkey exists for this item it will not be replaced; this new hotkey will simply be added. When you Ctrl-click, a message will appear at the top of the screen asking you to enter a key combination to save as a hotkey (Figure 11.12).

Hotkey prompt

Figure 11.12. Hotkey prompt

If the key combination you press is already assigned as a hotkey, ZBrush will notify you with a warning box. By answering yes you will replace the existing hotkey with your new selection. If you specify no, the action will be canceled. To save your hotkeys for the next ZBrush session, click Preferences → Hotkeys and click the Store button.

Customizing the Interface

ZBrush comes with several custom interfaces for you to choose from. You may find that one of the interfaces other than the default suits your working methods better. You can scroll through the various interfaces with the Load Next User Interface Layout button in the upper right of the screen (Figure 11.13). Clicking the Load Previous User Interface Layout will move back. Figure 11.14 shows a sample of some of the interfaces available.

ZBrush interface layout examples

Figure 11.13. ZBrush interface layout examples

Some available ZBrush interfaces

Figure 11.14. Some available ZBrush interfaces

In addition to custom user interfaces, ZBrush offers several preset color schemes. You can change the colors in the Preferences → IColors menu, but for a quick harmonious color scheme try clicking the Load Next (Previous) User Interface Colors button (Figure 11.15). Figure 11.16 shows several of the custom color sets available to you.

Colors

Figure 11.15. Colors

Some available ZBrush Custom Color sets

Figure 11.16. Some available ZBrush Custom Color sets

Setting a Save Hotkey

In this section we'll use what we have learned so far to create a custom ZBrush interface tailored to our needs. This will include hotkeys, custom button positions, as well as a custom menu set. You may decide to create this based on the default menu set, or if there is another menu layout you prefer, simply select that one and follow the exercise. This will base your custom menu on this other menu layout.

Saving the hotkey

Figure 11.17. Saving the hotkey

  1. To use these steps, you must have the ZPlugin quickSave script by Svengali installed. If you haven't already installed it, follow the instructions at the start of this chapter. Open the ZPlugin menu from the top of the screen and unroll the Svengali menu.

  2. Ctrl-click the M+ button to set a hotkey for saving the iteration. Because the Alt button is used so much for navigation and sculpting in ZBrush, I tend to use it for hotkeys since my thumb is usually there while I work. I set my save iteration hotkey to Alt+S.

  3. To save this new hotkey addition for future ZBrush sessions, go to the main Preferences menu and click Hotkeys to unroll that menu. Here you will click Save to store the startup hotkeys file, including the key we just set. See Figure 11.17.

Now we have a hotkeys set to save iterations of our model. We'll still need to use the Model Save button to save the first instance of the ZTool to establish the filename. This would be a good button to move from this nested menu into the interface itself. To do this, we need to turn on Custom Interface in the Preferences menu:

  1. Click the main Preferences menu and unroll the Custom UI submenu. Here you will find a button marked Enable Customize (Figure 11.18). Switch this on to allow you to move interface items around.

  2. With Enable Customize on, the Ctrl-click function will not assign hotkeys. Instead, it will allow you to drag buttons from one interface location to another. Dock the ZPlugin menu on the side of the screen and open the Svengali menu. Ctrl-drag the Model button and place it on the top tray. As you drag a button over an area where it can be docked, you will see a rectangle appear (Figure 11.19). Release the button in the top tray. The Model button is now placed in the top tray for easy access (Figure 11.20).

    Custom interface

    Figure 11.18. Custom interface

    Docking buttons

    Figure 11.19. Docking buttons

Setting the Interactive Light Hotkey and Button

We'll now place the button for Interactive Light into the main screen as well as set a hotkey for it. Again the hotkey will be centered on the Alt button.

Placing the Model button

Figure 11.20. Placing the Model button

  1. Click the main ZPlugin menu and open the Misc Utilities submenu. Here you will find the InteractiveLight button for moving the light source with the mouse (Figure 11.21). This helpful utility is a prime candidate to be assigned a hotkey and placed within easy reach.

    Note

    Remember that the interactive light will only work with Standard materials and not the MatCap shaders since the lighting model is baked into the MatCap materials.

    Misc Utilities

    Figure 11.21. Misc Utilities

  2. Ctrl-drag the InteractiveLight button from the ZPlugin → Misc Utilities menu and drop it into the top toolbar (Figure 11.22). Place it beneath the Model button.

  3. To set a hotkey for this button, we need to turn off Custom UI. This is because Ctrl will drag buttons while in Custom UI mode and will not set hotkeys. Return to the main Preferences menu and turn off Enable Customize under Customize UI menu.

  4. To assign a hotkey, simply Ctrl-click the InteractiveLight button. I set this hotkey to Alt+Q.

Another function I use often while sculpting is switching between a few of my favorite materials. I use Flat Color to check silhouette, Basic Material to interactively light, and White Cavity for brightness and detailing. To set hotkeys for these three materials, simply open the Material palette and Ctrl-click the material you want to assign hotkeys to. I assign Alt+1 to Flat Color, Alt+2 to Basic Material, and Alt+3 to White Cavity.

Interactive light

Figure 11.22. Interactive light

At this point, save your new interface and hotkeys. To do this, open the Preferences menu and, under the UI submenu, click Save. Under Hotkeys, click Save. This will store your custom UI as the default and the hotkeys added will be appended to the startup hotkeys file.

Naming your menu

Figure 11.23. Naming your menu

Making a Custom User Menu

In this section we'll create a new main menu interface item filled with custom menu options. Once this menu is set, we can assign it a hotkey, which will create a custom pop-up menu item containing your favorite items.

  1. In the main Preferences menu, under the Custom UI heading, click Enable Customize.

  2. Click the Create New Menu button. ZBrush will prompt you for a menu name (Figure 11.23). For this example, call this menu Scott.

  3. A new menu named Scott will appear in the main menu bar. Tear this empty menu off to the side of the screen by clicking the radial button so we can begin to add new interface items (Figure 11.24).

    The empty Scott menu

    Figure 11.24. The empty Scott menu

  4. First we'll add a couple of the most-used brush icons to this menu. From the Brush menu, Ctrl-drag the Standard brush icon to the Scott menu. In Figure 11.25, I have placed four of my most commonly used brushes in the Scott menu. Be sure that you drag the brush icons from the Brush menu, not from the main brush icon; the icon only represents the current brush selection (Figure 11.26). This is true for the Texture, Alpha, and Material menus as well.

    Scott brushes

    Figure 11.25. Scott brushes

    Brush selection

    Figure 11.26. Brush selection

  5. Now add a divider between the brush section and the next selection of menu items. In the Custom UI section of the Preferences menu you will see several orange bars. These can be Ctrl-dragged into the interface to serve as dividers and blank spots. Ctrl-drag the long orange bar into the Scott menu, as shown in Figure 11.27.

    Creating a bar divider

    Figure 11.27. Creating a bar divider

  6. Beneath this new divider, we'll place the icons for the Freehand and DragRect strokes. Use Ctrl-drag to dock these buttons, as shown in Figure 11.28.

    Strokes

    Figure 11.28. Strokes

  7. The custom menu is now complete. You can continue to add items to your own menu. If you Ctrl-drag the Custom Subpalette item to the menu, you can even add a custom "subpalette." To name your custom menu, Ctrl-click it (Figure 11.29). Figure 11.30 shows my custom menu with a submenu that contains the Edit, Move, Rotate, and Scale buttons. This submenu can be collapsed just like any other submenu in ZBrush.

  8. Now click the main Preferences menu and under Custom UI turn off Enable Customize. To save the changes you have made to the UI, click the Store Config button under the Preferences → Config menu.

  9. The final step is to assign a hotkey to the custom menu you just created. This will allow you to invoke this menu at the cursor position anywhere in ZBrush, much like a marking menu in Maya. To assign a hotkey, Ctrl-click the menu name at the top of the screen and press the desired key or key combination. I set mine to Alt+W. Now I can access my custom menu from anywhere in ZBrush (Figure 11.31).

Naming the submenu

Figure 11.29. Naming the submenu

My menu

Figure 11.30. My menu

My menu screen

Figure 11.31. My menu screen

Changing Your Default Document

It is possible to change the size, orientation, and color of your default document window when ZBrush starts. This is a simple process:

  1. Initialize ZBrush or create a new document by opening the main Document menu and clicking New Document (Figure 11.32). This will clear any tools and create a fresh document on which to work.

  2. If you simply want a bigger document than the default size, click the Double button. This will double the current document size; the ZBrush default is 960x720, so this will create a document that is 1920×1440.

  3. You may decide that you prefer a document that is oriented in portrait style rather than landscape. In that case, turn off the Pro button. This button constrains proportions. With this button off, you can enter exact image dimensions in the Width and Height sliders. To enter a value, click the slider to highlight the numbers and type the value you want. Try using a document that is 720x960. This will rotate the workspace 90 degrees.

    Click the New Document button.

    Figure 11.32. Click the New Document button.

  4. Click the New Document button.
  5. Click the New Document button.
  6. Click the New Document button.

Changing the Startup Material

In addition to changing the startup document size, you can change the default material. ZBrush loads with the MatCap Red Wax material selected by default. Follow these steps to change your default material:

  1. Open the main Material menu and select the MatCap Red Wax material. Click the Save button and save this material as RedWax.zmt in Pixologic/ZBrush3/ZStartup/Materials. We are saving this material since we need to copy our preferred startup shader into this slot. By saving the MatCap Red Wax material into the startup materials folder, you ensure that it will still be available when ZBrush starts.

  2. Changing the Startup Material
  3. Select the MatCap Red Wax material again and click the PasteMat button to replace the RedWax material with the Basic Material.

  4. Clear the canvas and set your document to the dimension you want the ZBrush canvas to be as a default each time you start the program. Select the Simple brush from the Tool menu and with just M and ZAdd active on the brush, create a small stroke in the corner of the canvas (Figure 11.33).

    Adding a small stroke to the corner of the canvas with the new default material

    Figure 11.33. Adding a small stroke to the corner of the canvas with the new default material

  5. Save this document as StartupDocument.zbr in the Pixologic/ZBrush3/ZStartup folder. Overwrite any previous startup document you may have saved. Restart ZBrush and you will find it loads with your new default material. The Red Wax shader will also still be available in the Startup MatCap Materials.

Congratulations! You have just completed building a complex custom user interface for ZBrush. Customizations like this can help you harness the power of this program and increase your speed greatly. Knowing exactly the options you want and having them at your fingertips can make working in ZBrush smoother, faster, and more efficient.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.104.248