1. #1

    Default How To Quit ZBrush From ZScript?

    I can get the Close 'x' box to activate which brings up the save or not dialog box but I can't hit the 'n' button to finish the process, from a ZScript:


    [IButton,Play,"Press to play this ZScript. ZScript can be aborted at anytime by pressing the ëescí key.",
    [IConfig,4.8]
    [IPress,Close]
    [Delay,3]
    [IKeyPress,"n"]
    ]/*End of ZScript*/

    The Delay doesn't help. The key press doesn't seem to happen, to not save, and thus finish quitting.

    I need to quit since I'm invoking ZBrush from a Python script from another program (Rhino Grasshopper) but my Python subprocess needs to know the process is done and over or it freezes up and I have to manually quit ZBrush.

    [This may be a blessing in disguise since it's slow to keep restarting and quitting ZBrush and I may be able to communicate in some other way with my Python script if I can figure out how to get it to launch ZBrush with a ZScript and then not just freeze up, but say, check every second if a file has been modified, or something.]

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    You need to use uppercase "N" and wrap the IKeyPress around the [IPress,Close]. You can use the ASCII code 78 instead of "N" but both work:


    [IButton,Play,"Close ZBrush without saving project",
    [IConfig,4.8]
    [IKeyPress,78,[IPress,Close]]
    ]/*End of ZScript*/


    Also, if you are launching ZBrush from python with a zscript then you need to make sure the zscript will run automatically by wrapping the second level commands inside an [If,1,] statement (that is always true).

  3. #3

    Default

    Formatting issue, I see.

    I've figured out how to not have ZBrush freeze up my Python program by using subprocess.Popen() instead of subprocess.call() and then using a time.sleep() while loop to wait until the output file can be opened for appending. So I don't have to quit ZBrush any more.

    However, I still have to learn to then return focus to my Python program in Windows. The ZBrush Hide button fails most of the time, even manually, unless I first use Restore, but even then it's not reliable. It may have to do with being opened initially in a subprocess of another program.

    This seems to work from Python, to put ZBrush back in hiding:

    import ctypes
    zbrush_handle = ctypes.windll.user32.FindWindowW(u"ZBrush", None)
    ctypes.windll.user32.ShowWindow(zbrush_handle, 6)

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Formatting issue, I see.
    Not exactly. Lowercase "n" will not work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •