Pass GetParameterAsText variable between Python Scripts in an imported Toolbox

320
1
01-16-2019 12:12 PM
JoeBryant2
Occasional Contributor II

I'm having a hard time finding an exact answer to this question when searching the keywords (deep topics, lots of rabbit holes!)

Big picture: I am trying to create a single tool that novice GIS users at our office can run, that only requires a single feature class input from a weekly updated geodatabase be chosen as the input parameter. The rest of the processing, archiving, and appending of the production geodatabase stays the same and is completely automated.

I have created 3 Python scripts that are meant to be used in series for each step of this process (they are actually exports from ModelBuilder that I have modified to work in an Enterprise Geodatabase environment). The first one selects the new feature class and processes the geometry and attribute fields in preparation for replacing our current production feature class. The next script creates an Archive of the current production feature class that can be used for comparison with the new feature class. The last script truncates the current production table and then appends it with the newly prepared feature class.

I created a new toolbox with a new "toolset" in ArcCatalog, and have successfully created the 3 script tools using the original 3 Python scripts. The first python script has an input variable defined using "PARCELS = arcpy.GetParameterAsText(0)" in the code. I have also updated the script tool properties to use a parameter for this step (named PARCELS, feature class, required, input).

I have been attempting to create a "master" script that imports the toolbox and calls each script process, using the ArcPy module to write the code. Once this works, I will save the code as a script tool of its own. But I'm having trouble passing the user defined input variable to the master script.

When I "Open" or double-click on the first script tool (with the input parameter) in ArcCatalog, I successfully get the pop-up asking me to select the feature class to be used as the input.

But if I use the ArcPy module in ArcMap to import the toolbox and call the script, I am not prompted for the parameter, but instead get the message: "Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "D:\ParcelUpdates\ParcelToolbox.tbx", line 229, in CreateCWDParcels     ExecuteError: Failed to execute. Parameters are not valid. ERROR 000735: PARCELS: Value is required Failed to execute (CreateCWDParcels)."

Am I approaching this the right way? Can someone point to a straightforward example? (Note that a ModelBuilder tool will not work for this process because of field mapping issues when appending between a file geodatabase and an enterprise geodatabase).

0 Kudos
1 Reply
MarisaClaggett
Occasional Contributor II

Hi Joe,

To confirm, are you saying that when using the python window in ArcMap rather than running the script tool as a tool, you receive this error?  Do you have any screenshots of the lines you use in the python window to perform this workflow?

Best of luck,

Marisa

0 Kudos