AnsweredAssumed Answered

arcpy make Parameter to be both input/output

Question asked by yosuke on Mar 11, 2015
Latest reply on Mar 12, 2015 by yosuke

Hello,

 

Is it possible to have a arcpy's Parameter which act as both input and output?  Specifically,

 

  • The parameter is for a file (CSV file)
  • If specified file does not exist, create one and use it as output (this is how my script is written)
  • If specified file exists, read it, do some consistency check with other inputs, and then append to the file
  • If specified file exists but doenst make sense, just delete and start over

 

I thought about different way to make this happen, but issues I have are

  1. if parameter is output, then the file got deleted before execute() method got called.  so I cannot use output
  2. if I make parameter to input, the toolbox's dialog doesn't let me specified non-existent name, forces me to pick existing file name.  that's not what I want, because the file is actually output
  3. so I may set parameter as output, and do the testing in updateMessage() method, and if I want to append, I copy the parameter value to a hidden input parameter and then delete value from the output parameter?  is this feasible?
  4. I can have two boxes, one for input, other for output, and pick the one that make sense.  but. the UI is going to be very confusing.
  5. one other way is to not set this parameter to string was something.  but then the file browser like behavior of the UI doesn't work (is there way to use the browser like interface for any variable?

 

If there is some simple method to do this, please let me know.

Outcomes