ZBrushCentral

Zpython

Hi all,
here is a small and dirty example on using python to automatize ZBrush:

import win32com.client,win32api

shell = win32com.client.Dispatch(“WScript.Shell”)
#shell.Run(“c:\z2\zbrush2\zbrush2.exe”)
#win32api.Sleep(100)
shell.AppActivate(“ZBrush”)
win32api.Sleep(1000)
shell.SendKeys(“g”) #activate the well-known ProjectionMaster plug in :wink:
win32api.Sleep(2500)

How to use:
Save the previous code as Z.py
Run ZBrush
Run Z.py (double-click from Explorer)

You must have python and pythonwin installed (www.python.org)

I hope this idea will help you to experiment …

cameyo

p.s. Vote “ZBrush for Linux” in this thread http://www.zbrushcentral.com/zbc/showthread.php?p=232757#post232757

Hello Cameyo
Projection Master is yet enable whe you run Zbrush :confused:
What is the + of this script ?
I am perplex :smiley:
Pilou

I think it’s an interesting experiment. Unless you have better intereface into zbrush than sending keystrokes to it through the shell I kind of doubt that you’ll be able to accomplish much.

Can you show us more?

This is cool. I wonder what the obstacles are to reading directly from Zbrush’s memory to discover data that is not usually exposed by the zscript API? For instance, might it be possible to reliably locate marker information in memory and expose this through an alternate interface? Can we get that to work on the mac too? What’s the best way to discover those addresses and the data structures involved, how are the locations likely to change from machine to machine? Who can know such things except the man himself?

Hi all,

Frenchy: it’s not a plus ready to go, but only a small experiment to drive ZBrush from outside:D

BillRobertson: beside sending keystrokes to Z you can call DLL functions, work with external file and drive mouve on canvas…i hope pixologic will release the internal format of ZTL, ZBR, etc.

Antimorph: On Mac python works well, but you must have some method to call ‘sendkeys’. I have no time to discover all the data-pointer of Z, but i think Pixologic can integrate python inside ZBrush (only a hint)

Anyway, it’s only a joke, but i hope some other people thinks about this possibility.

Thanks for viewing.

cameyo

Cool :slight_smile:

now I must learn python :):+1:

thanks for shareing this neat technique

I’ve tried running this script with zBrush 3.1 and I havent had any luck. I’m using python 2.5, windows 7 - 64 bit. I’ve run zBrish as administratr and compatibility as XP and Vista.

I’ve tried modifying: shell.AppActivate(“ZBrush”)
to “ZBrush3”, ZBrush3.1, its just the name of the process in the task manager right? Any help would be appreciated :smiley:

I needed to get the name of the active window and for some reason “Zbrush” is not the correct name. So I have python get the active window name, save it as a variable and in a loop I send a key command. Saving the z app name to a variable lets me error check in case some other application is active. You would not want this script sending key commands while you’re writing an email :). This can be used to create an auto-saving script for zBrush. Well as long as you can assign a zscript to a hot key.

my apologies about the formatting:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Import Modules import win32com.client import win32api import win32gui import os # Main timer_on = 1 #set the inf loop variable #create shell script

shell = win32com.client.Dispatch(“WScript.Shell”)
#create command to fire up Z
command = “C:/Program Files (x86)/Pixologic/ZBrush3/ZBrush3.exe”
#os.startfile(command) #fire up Zgg
win32api.Sleep(5000) #pause for z to load
#get title window of z
winName = win32gui.GetWindowText(win32gui.GetForegroundWindow())
#save title window of z
zWin = winName
#pause for z to be active
win32api.Sleep(5000)
#make sure z is active app
shell.AppActivate(“zWin”)
while(timer_on > 0):
#sleep for 5 minutes before sending key command
win32api.Sleep(5000)
shell.AppActivate(“zWin”) #making Z active app
win32api.Sleep(1000) #pause before saving
if (zWin == winName): #make sure its Z
shell.SendKeys(“w”) #initiate move command in Z
print “Sending Z Command” #print statement for error check
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++