Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: michaelzhangxc on April 07, 2014, 06:08:45 PM

Title: how to input arguments to a script
Post by: michaelzhangxc on April 07, 2014, 06:08:45 PM
I tried to input arguments to a script through Run Python Script dialogue window, but failed. The code is is as below:

AA=input('input argument AA:')
print (AA)

bb=input('input argument bb:')
print (bb)



Reffer the attached picture.

Console message:
Traceback (most recent call last):
  File "C:/Python33/try.py", line 4, in <module>
    AA=input('input argument AA:')
RuntimeError: input(): lost sys.stdin

Anyone can help? Thanks in advance.
Title: Re: how to input arguments to a script
Post by: Alexey Pasumansky on April 07, 2014, 06:21:06 PM
Hello michaelzhangxc,

You need to use sys module to access arguments:

Code: [Select]
import PhotoScan
import sys

input = sys.argv[1]

print(input)

Please note that "input" variable is string.
Title: Re: how to input arguments to a script
Post by: michaelzhangxc on April 07, 2014, 07:11:21 PM
that was quick Alexey, thank you. Now it works perfect.