Has anyone gotten python to communicate with zBrush? I want to work around some limitations of zScript but I’ve had no luck.
This is based off a post from zbrushcentral. There was a post about sending key commands from python to zbrush. The code posted there didn’t work with Zbrush3. 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. I would not want this script sending key commands while I’m writing an email . My intention is to create an auto-saving script for zBrush; as long as I can assign a zscript to a hot key. Its not pretty but it works
Here is the post from zbrush central: http://www.zbrushcentral.com/showthread.php?t=29295
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
#pause for z to load
win32api.Sleep(5000)
#get title window of z
winName = win32gui.GetWindowText(win32gui.GetForegroundWindo w())
#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)
#making Z active app
shell.AppActivate("zWin")
win32api.Sleep(1000)
if (zWin == winName):
shell.SendKeys("w") #initiate move command in Z
print "Sending Z Command" #print statement for error check
++++++++++++++++++++++++++++++++++++++++++++++++++