WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-27-2003, 10:29 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
Passing arguments to vizard script

Farshid,

Thanks for your help on starting Vizard from the command line. I have another related question.

Is it possible to pass other arguments to the Vizard script from the command line, i.e.,

>"C:\Program Files\Vizard\bin\Vizard.exe" myscript.py arg1 arg2 -r

That is, I want to be able to use arg1 and arg2 for other things within my Vizard script.

Thanks,
Andy
Reply With Quote
  #2  
Old 03-27-2003, 10:39 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi Andy,

Currently the only argument available is "-r" which runs the file.
I just added another argument "-e" which exits the program. This will be available in the next release. If there are other arguments you'd like to pass, just request them here and I'll see what I can do =)

-- farshid
Reply With Quote
  #3  
Old 03-27-2003, 10:56 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
Well, one example of what I'd like to do is pass the name of another file that I'd like my Vizard script to open and write to. So if I typed the following, for example:

>"C:\Program Files\Vizard\bin\Vizard.exe" myscript.py -r out.dat

Then somewhere in myscript.py, I could use sys.argv to retrieve the filename (out.dat) then open it to write some data to it, for example.

Maybe the way to go is like the typical UNIX args, which call for something like

>Vizard.exe -r myscript.py -a arg1 arg2 ...

where -r indicates the script that should be run, and -a indicates additional arguments that should be passed to the script.

Thanks
Andy
Reply With Quote
  #4  
Old 03-27-2003, 01:58 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi Andy,

That sounds easy enough =)
I'll try to add the "-a" command in the next release.

-- farshid
Reply With Quote
  #5  
Old 04-25-2003, 12:31 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi Andy,

I just wanted to update you on a new feature of vizard.
You can now pass arguments to a script from the command line.
For example if you wanted to specify an input and output file you would do the following:

>"C:\...\Vizard.exe" myscript.py -r -a in.dat out.dat

Then in your vizard script you would read in the arguments through the variable 'viz.args', which is a list of strings. In the example above, viz.args would be ['in.dat','out.dat']

-- farshid
Reply With Quote
  #6  
Old 05-01-2003, 07:06 AM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
Hi Farshid,

I've just tested it out and it works as advertised - thanks.

Andy
Reply With Quote
  #7  
Old 05-01-2003, 03:36 PM
hotspur1 hotspur1 is offline
Member
 
Join Date: Mar 2003
Location: Cambridge, MA
Posts: 54
Hi Farshid,

Sorry to bother you again, but I did notice some odd behavior when passing args from the command line. I wanted to pass more than one arg, so I tried grabbing the first one using

viz.args[0]

Now this works fine according to the Vizard interactive window output, but when I check the DOS command window, it shows up as an empty list! I also get an error that the index is not valid!

As I understand the engine, the script is actually parsed twice, so perhaps the variable is getting lost when sent through the second time!

I tried copying the list to another variable using

arglist = viz.args

but the same behavior occurs. The Vizard window has happy output, but the DOS window shows an empty list. As long as I don't try to access the string, the program will obviously runs, but when I try to access a list member, it obviously can't find it.

Any suggestions?

Thanks
Andy
Reply With Quote
  #8  
Old 05-02-2003, 02:03 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi Andy,

That's my mistake. You are correct about the script being parsed twice, and I simply forgot to set the args for the second parse. I'll fix this as soon as possible. Sorry about that.

-- farshid
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 09:28 PM.


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