Model Builder exported to Script defciency

341
3
02-21-2019 01:57 PM
KarenWitsell
New Contributor II

Exporting a script from model builder with the hope of creating a functional python script. I need to be able to have the option of selecting my inputs. Some locations have data while others do not. I want to be able to run the script and select my inputs, while ignoring other inputs. I have multiple potential feature classes as inputs. I've identified these as variables but after running the python script, I receive the following error message. 

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000735: Input Datasets: Value is required
Failed to execute (Merge).

Here is the script: 

# Import arcpy module
import arcpy
# Script arguments
PotentialArea_A = arcpy.GetParameterAsText(0)
ProtectiveZone_A = arcpy.GetParameterAsText(1)
Wetland_A = arcpy.GetParameterAsText(2)
...
# Local variables:
Merge = "...Merge"
Dissolve = "...Dissolve"
# Process: Merge
arcpy.Merge_management("'';'';'';'';'';'';'';'';'';''", Merge, "")
# Process: Dissolve
arcpy.Dissolve_management(Merge, Dissolve, "", "", "SINGLE_PART", "DISSOLVE_LINES")
0 Kudos
3 Replies
ColeAndrews
Occasional Contributor III

If you want the geoprocessing to be interactive ("need to be able to have the option of selecting my inputs"), then what is the reason you do not want to leave it as a tool/model in ArcGIS? 

0 Kudos
KarenWitsell
New Contributor II

I would like to move the code into python and out of model builder. I think the model itself is not as functional as I want it to be. Hoping to find more functionality in python. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

Karen, your input parameters should be associated with parameters in a toolbox,

Running the script in standalone mode, given the number of parameters, would require you to do a lot of typing.

If you haven't created a convention tool in Arctoolbox, and are using ArcGIS Pro, then have a look

/blogs/dan_patterson/2016/05/19/toolbox-creation-in-arcgis-pro 

The principles are essentially the same as in ArcMap.