Original User: jbarryThanks Chris.I'll test a few things, browsers, versions, line lengths, etc. and see if I can figure this out. Of course we shouldn't be adding or removing extra spaces or characters, etc.Until then, at least for code samples, you might like using the CODE blocks for this. (Tool button on the text editor with the # symbol on it.) For example, does this below look ok to you?%%%%%%%%%%
% TEST BELOW
%%%%%%%%%%In your script does the first line restrict the loop to only the reference layer? I need the If statement to look at the referred layer only as there is a master layer in the same directory that would have 'Murray Inland'. This script is part of a geoprocessor model where the 'clip feature' is derived from user input. I have also noticed the 'while' loop significantly increases processing time. Could a 'for' loop be used instead of 'while'? The loop I'm attempting is:
fieldname = "Region"
gp.workspace = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature"
shp = gp.ListFeatureClasses()
for shp in shp:
if fieldname == 'Murray Inland':
gp.Delete_management("C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines\\Contour.shp")
This loop has the problem of not being specific to the 'clip feature' layer and also looks at the master layer.I have attempted to run the supplied while loop script which executes successfully but gives an error that the contour layer does not exist. My complete script is shown below:
import sys, string, os, arcgisscripting
gp = arcgisscripting.create(9.3)
Contours = "\\\\Atlas\\data\\geodata\\state\\contour\\arc "
Crossings = "\\\\Atlas\\data\\geodata\\state\\crossings\\arc"
Contour = "Contour.shp"
Crossing = "Crossing.shp"
P_L = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines"
Clip_Feature = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature\\Clip_Feature.shp"
gp.FeatureClassToFeatureClass_conversion(Contours, P_L, Contour, "")
gp.FeatureClassToFeatureClass_conversion(Crossings , P_L, Crossing, "")
gp.workspace = "C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Clip_Feature"
scursor=gp.SearchCursor(Clip_Feature)
row=scursor.Next()
while row:
if row.GetValue("Region") == 'Murray Inland':
gp.Delete_management("C:\\Daves_Stuff\\ArcPad_Data\\Standard_Layers\\Lamberts_Projection\\Pts_Lines\\Contour.shp")
del scursor