2

I have been working on this script tool in ArcGIS Pro. The following code is what I got so far to create a tool in ArcGIS Pro, connected to the script, that takes parameters from users (initially, the geodatabase filename) and shows the report that lists the feature classes it contains to the console on the screen.

import arcpy
import os
arcpy.env.workspace = arcpy.GetParameterAsText(0)
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:    
    arcpy.AddMessage(fc)

Now, for my next step, I am trying to add a code that gives users the option for showing the report on the screen or creating a text file.

What function do I need to do this?

3

To do this you will need to add at least one more parameter to your Python Script tool.

Try changing:

arcpy.env.workspace = arcpy.GetParameterAsText(0)

to:

arcpy.env.workspace = arcpy.GetParameterAsText(0)
createTextFile = arcpy.GetParameter(1)

You will then need to configure that second parameter on your tool dialog as being a Boolean.

That way you can write code like:

if createTextFile:
    # Write code to create text file
else:
    # Display messages like you are doing now
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.