0

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."
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 4, 2015 at 15:00
5
  • Can you please edit you post to use code formatting? It's very hard to read currently as a wall of text. Commented 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. Commented 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. Commented Aug 4, 2015 at 15:25
  • @TristanForward raw string is not required as the string variable does not contain any backslashes. Commented Aug 4, 2015 at 23:23
  • Can you edit your post to add the entire error traceback, not just the final error message. Commented Aug 5, 2015 at 0:11

1 Answer 1

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
answered Aug 4, 2015 at 15:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.