ecopirate

How do you successfully pass a variable from ModelBuilder to an python script?

Discussion created by ecopirate on Jul 27, 2012
Latest reply on Jul 31, 2012 by mzcoyle
Dear ArcGIS Geoprocessing Folk,

A rather general and I guess somewhat basic question:

My model (in ModelBuilder) keeps updating a string variable, %output_value%, that is the only precondition to a python script (also in the model). How do you successfully pass that variable (from ModelBuilder to the in-model python script) so that it becomes an in-script string variable (eg. InScriptVar) equal to the new value of %output_value% each time the python script is called by the model.

What is the easiest way/trick to debug and see what is really going on with variables inside a python script when that script is executing embedded inside of a ModelBuilder workflow?

I see the relevant help section here:

'>http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Integrating_scripts_within_a_model/002w0000006n000000/


which mentions setting up parameter properties on the script
and then shows the use of the following setup code:

 import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)
tablePath = gp.GetParameterAsText(0)


But only provides just one example...

Why is it necessary to import arcgisscripting in such a way and where is this further documented?
Is this still the best way to do things in ArcGIS 10.1?
Where are there more examples of doing this?


Many thanks in advance for any suggestions.

Ian

Outcomes