I am stuck with a code due to a RunTimeError: Object: Error in Executing tool and I really can't find the mistake. The code is
# Now, the script for "Adding Surface Info" to the network, using the raster with MAX MEAN defined just above
# Set the raster of input, on the basis of the MAX MEAN
inSurface = "C:/B3061239/!!! WORK !!!/RAS_for_maxmean/", NameRasList[MEANlist.index(max(MEANlist))]
# NOTE that NameRasList[MEANlist.index(max(MEANlist)) has been calculate before
method = "BILINEAR"
if inSurface:
print "Got inSurface"
# Create list of feature classes
fcList = arcpy.ListFeatureClasses()
print str(len(fcList))
# Process: Add Surface Information
if fcList:
print "Got featureclasses"
for fc in fcList:
desc = arcpy.Describe(fc)
print desc.name
# Determine if the feature is 2D
#if not desc.hasZ:
#if desc.shapeType == "Polygon":
# Desired properties separated by semi-colons
#Prop = "Z_MIN;Z_MAX"
#elif desc.shapeType == "Point":
#Prop = "Z"
#elif desc.shapeType == "Multipoint":
#Prop = "Z_MIN;Z_MAX;Z_MEAN"
#elif desc.shapeType == "Polyline":
#Prop = "LENGTH_3D"
# Execute AddSurfaceInformation
arcpy.ddd.AddSurfaceInformation(fc, inSurface, "Z_MAX", method, "", "1", "0", "NO_FILTER")
print "Completed adding surface information."
asked Aug 4, 2015 at 15:00
-
Can you please edit you post to use code formatting? It's very hard to read currently as a wall of text.Tristan Forward– Tristan Forward2015年08月04日 15:24:24 +00:00Commented Aug 4, 2015 at 15:24
-
Is this a real path to some data : inSurface = "C:/B3061239/!!! WORK !!!/RAS_for_maxmean/"? I would certainly get rid of the spaces and "!!!" stuff. If you want a real answer for this, start by telling us ArcGIS version etc and perhaps provide the code and actual error message you are getting.Neil Ayres– Neil Ayres2015年08月04日 15:25:35 +00:00Commented Aug 4, 2015 at 15:25
-
Try changing inSurface = "C:/B3061239/!!! WORK !!!/RAS_for_maxmean/" to "inSurface = r"C:/B3061239/!!! WORK !!!/RAS_for_maxmean/" The change is the raw string "r" its hard to see the change.Tristan Forward– Tristan Forward2015年08月04日 15:25:42 +00:00Commented Aug 4, 2015 at 15:25
-
@TristanForward raw string is not required as the string variable does not contain any backslashes.user2856– user28562015年08月04日 23:23:10 +00:00Commented Aug 4, 2015 at 23:23
-
Can you edit your post to add the entire error traceback, not just the final error message.user2856– user28562015年08月05日 00:11:44 +00:00Commented Aug 5, 2015 at 0:11
1 Answer 1
Consider using an error handler to locate the source of the error....
try:
import sys, traceback
#YourCodeHere
except arcpy.ExecuteError:
print "error"
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
print msgs
except:
print "error"
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
print pymsg + "\n"
Tristan Forward
2,2173 gold badges25 silver badges43 bronze badges
lang-py