debragajdosFM0

Py 2.4 - using sys.argv with gp.Feature Class to Coverage

Discussion created by debragajdosFM0 on Feb 7, 2012
Latest reply on Feb 20, 2012 by debragajdosFM0
Hello everyone,

I am trying to put the gp tool into a script (see my post about os.walk and sys.argv). The proccessing tool looks like this in script form:

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Set the necessary product code
gp.SetProduct("ArcInfo")

# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx")

# Script arguments..

##lines_shp = sys.argv[1]

lines_shp = "C:\\test\\lines.shp"

# Local variables...

# Process: Feature Class To Coverage...
gp.FeatureclassToCoverage_conversion("C:\\test\\lines.shp ARC", lines_cov, "", "DOUBLE")



This works when I run it in IDLE ver 1.1.1.

But when I try to use the sys.arg like this:

# Script arguments..

lines_shp = sys.argv [1]

##lines_shp = "C:\\test\\lines.shp"

# Local variables...

# Process: Feature Class To Coverage...
gp.FeatureclassToCoverage_conversion("lines_shp ARC", linesCopy_cov, "", "DOUBLE")




I get this error:

Traceback (most recent call last):
File "C:/scripts/FC to Cov script.py", line 29, in ?
gp.FeatureclassToCoverage_conversion("lines_shp ARC", linesCopy_cov, "", "DOUBLE")
NameError: name 'linesCopy_cov' is not defined
>>>


So I guess my question is, why does FC to Coverage only play nice if the path is hard coded into the gp line? I've written other scripts and used sys.argv with no problem...

Thanks in Advance.

Outcomes