Select to view content in your preferred language

How to allow a python tool parameter to accept a save location for a file that does not exist yet? Skip/modify parameter validation?

297
3
Jump to solution
2 weeks ago
Glasnoct
Regular Contributor

I'm trying to give my python tool an input parameter that allows the user to select the export location/file path that the script will save the resulting feature class to. The problem is that if I want to give the user the functionality of a parameter with a data type that provides the 'browse' icon next to the text box, the parameter validates the chosen path when they confirm and if the file does not exist (because they manually entered a new feature class name to use) then the parameter throws up the little red "invalid" icon. 

A built-in tool like "Export Features" auto-populates the output path when the input is selected but from looking at the tool properties, I can't tell how that's accomplished or how it avoids throwing an error.

How do I need to define my Parameter instance to accept that the value may be an "yet to be created" file? So I need to mess about with the ToolValidator class with which I have no experience yet? 😥

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

are you setting a Parameter with "output" as the direction?

Parameter—ArcGIS Pro | Documentation


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

are you setting a Parameter with "output" as the direction?

Parameter—ArcGIS Pro | Documentation


... sort of retired...
Glasnoct
Regular Contributor

No, it was an input. Switching it to output has fixed it. Input felt logical to me, though I could see it either way.

That documentation doesn't explain the distinction between input/output parameters other than the axiom "an output parameter is an output." I understand my path parameter is related to the output of the tool, but is it not an input considering it's a value passed into the tool that the code uses? An output parameter isn't shown in the code samples and I'd struggle to remember I time I've seen an output parameter used in any example I've seen elsewhere--this is the first time I've needed one, actually.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Here's what they don't tell you: In case of error or failure, output parameters get deleted.

Inputs hang out because they assume they're important, but for the most part they assume that the output doesn't exist yet, so there won't be any harm if it disappears.

0 Kudos