WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   starting Vizard from a Python script (

hotspur1 03-26-2003 10:11 AM

starting Vizard from a Python script
I would like to run a Vizard script from another Python script by something like


but when I try this, I get a dialog box that says Vizard must be running first. Also, when I click the 'ok' button, it seems to hang up the Pythonwin program.... Normally, I would not be using Pythonwin but the calling script would be executed from the Command prompt or equivalent.

Any thoughts on how I can do this?

Thanks in advance.

farshizzo 03-26-2003 10:32 AM


To run a Vizard script from the command line you need to execute
'Vizard.exe' and pass the file name and "-r" as the arguments. This will basically open up the main Vizard program and immediatley run the specified script. Here's an example:

C:\Program Files\Vizard\bin\Vizard C:\ -r

One thing to note, if there are spaces in the name of your script path you need to inclose it within quotes:

C:\Program Files\Vizard\bin\Vizard "C:\my" -r

Good Luck!

-- farshid

hotspur1 03-26-2003 11:04 AM


Thanks. That works like a charm! I think you put the quotes around the wrong part of the command in your example....

As a follow-up, is there a clean way to exit Vizard as well? I can exit the graphics portion with viz.quit() but is there a way to also exit Vizard.exe without using the menu option?

farshizzo 03-26-2003 12:27 PM


Currently there is no way to exit the main vizard program with a command, but I can easily add this feature for the next release.

For now you can do the following, which basically finds the handle to the vizard window and sends a close message to it:

import win32ui

VizardWindow = win32ui.FindWindow("WorldvizVizardClass",None)


Hope that helps!

-- farshid

hotspur1 03-26-2003 03:08 PM

Thanks for the workaround - although I discovered that I had to make sure that the Pythonwin package was installed to have access to the win32ui module. I was not running the python script via Vizard although, I suspect that I will do this eventually.

Thanks also for putting this feature into the list for the next release.

hotspur1 03-26-2003 03:18 PM

Oops - one more comment to my previous post. My Vizard script protests when I try to include the win32ui methods, or at least, I cannot use them after a call to vrut.quit() (It's in part of a keyboard event handler routine). If I don't use vrut.quit() then it seems to run ok. Will the future command allow me to shut down all windows?

farshizzo 03-26-2003 04:09 PM


Once vrut.quit() is called the program stops execution, that's why the win32ui commands aren't being called. Try running the win32ui commands before vrut.quit(). This should work fine since the main vizard program is a separate process than the winviz program. So your keyboard handler should look something like this:

def mykeyboard(key):

if key == 'q':
import win32ui
window = win32ui.FindWindow('WorldvizVizardClass',None)

Hope that works!

-- farshid

hotspur1 03-27-2003 07:23 AM

OK, that did the trick - thanks!


hotspur1 05-01-2003 08:11 AM

v1.09 include this type of quit
Just wondering if this functionality made it into v1.09? I can still use the workaround, but curious if there is a new method like


that handles it nicely?


farshizzo 05-01-2003 10:06 AM

Hi Andy,

There is no built in way of closing the main Vizard application, but you can pass it the '-e' flag through the command line to make it exit. This is probably nicer than the previous way, however I'll just go ahead and implement a "quitall()" method while I'm at it. =)

-- farshid

JRichizzle 03-14-2005 04:01 PM

Is this "quitall()" functionality now included in Vizard 2.50 or 2.51? I would like to be able to close Vizard.exe from within a Vizard script.

farshizzo 03-15-2005 12:16 PM

The command will not work. It was created before the ability to launch a script from outside the GUI. Here is the code for it if you still need it:

def quitall():
        #Send '-e' flag to vizard to make it exit
        path = _WIN_VIZ_PATH
        #Make sure vizard_path exists
        if len(path) > 0:
                if path[-1] != '\\':
                        path += '\\'
                path += 'bin\\Vizard.exe" -e'
                path = '"' + path
        #Now quit winviz

zumbay 06-12-2019 01:03 PM


is there a build-in function for closing the application by now?


All times are GMT -7. The time now is 08:54 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC