WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 03-26-2003, 10:11 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
starting Vizard from a Python script

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

os.execv("winviz.exe",['runthisVizardscript.py'])

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.
Reply With Quote
  #2  
Old 03-26-2003, 10:32 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

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:\myscript.py -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 script.py" -r

Good Luck!

-- farshid
Reply With Quote
  #3  
Old 03-26-2003, 11:04 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54


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?
Reply With Quote
  #4  
Old 03-26-2003, 12:27 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

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)

VizardWindow.SendMessage(16,0,0)

Hope that helps!

-- farshid
Reply With Quote
  #5  
Old 03-26-2003, 03:08 PM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
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.
Reply With Quote
  #6  
Old 03-26-2003, 03:18 PM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
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?
Reply With Quote
  #7  
Old 03-26-2003, 04:09 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

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)
window.SendMessage(16,0,0)
vrut.quit()

Hope that works!

-- farshid
Reply With Quote
  #8  
Old 03-27-2003, 07:23 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
OK, that did the trick - thanks!

Andy
Reply With Quote
  #9  
Old 05-01-2003, 08:11 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
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

viz.quitall()

that handles it nicely?

Thanks
Andy
Reply With Quote
  #10  
Old 05-01-2003, 10:06 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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
Reply With Quote
  #11  
Old 03-14-2005, 04:01 PM
JRichizzle JRichizzle is offline
Member
 
Join Date: Mar 2003
Location: Houston, TX
Posts: 43
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.
Reply With Quote
  #12  
Old 03-15-2005, 12:16 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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:
Code:
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
		os.system(path)
	#Now quit winviz
	quit()
Reply With Quote
  #13  
Old 06-12-2019, 01:03 PM
zumbay zumbay is offline
Member
 
Join Date: Oct 2016
Posts: 16
hey,

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

thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:48 PM.


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