1

This script works fine when the paths are hard coded for testing and executed in a Python IDE. After porting to a toolbox tool and tested with the same data the tool closes without error. No output data is created, none of the text in the add messages are displayed in the ArcGIS Pro v3.3 message dialog. Why does this toolbox tool do nothing?

import sys
import traceback
import arcpy
from arcpy import env
from arcpy.sa import *
try:
 
 
 arcpy.AddMessage('Detrend a Raster Surface Model by Euclidean Plane.')
 # Check out any necessary licenses
 arcpy.CheckOutExtension("3D")
 arcpy.CheckOutExtension("spatial")
 
 ##An inout surface of three non-colinnear points
 zpoints = arcpy.GetParameterAsText(0)
 ##The field in the point file that stores the z values 
 zvalues = arcpy.GetParameterAsText(1) 
 ##The surface model to detrend
 insurface = arcpy.GetParameterAsText(2)
 ##The output detrended surface
 detrendedsurface = arcpy.GetParameterAsText(3)
 
 
 # Hardcoded paths for testing #
 ##An inout surface of three non-colinnear points
 #zpoints = r'Z:\DetrendingToolsForPy3\fubar.gdb\fubar'
 ##The field in the point file that stores the z values 
 #zvalues = 'z' 
 ##The surface model to detrend
 #insurface = r'I:\SurfaceModels\GreenLiDARSouthFork2017\Bare_Earth_Digital_Elevation_Models\Clipped_Bare_Earth\clbe_nooksack_ft_WaSPNt.tif'
 ##The output detrended surface
 #detrendedsurface = r'Z:\DetrendingToolsForPy3\euc_trend.tif'
 
 #set variables
 arcpy.AddMessage('Setting environmental varialbles...')
 arcpy.env.extent = zpoints
 arcpy.env.snapRaster = insurface
 arcpy.env.cellSize = insurface
 env.cartographicCoordinateSystem = insurface
 
 
 arcpy.AddMessage('Creating Euclian plane.....')
 trend = Trend(zpoints, zvalues, cell_size = '', order="1", regression_type = 'LINEAR', out_rms_file ='')
 
 
 arcpy.AddMessage('Creating detrended surface...')
 outMinus = Minus(insurface, trend)
 outMinus.save(detrendedsurface)
 
 
 arcpy.AddMessage("Done without error!")
 
except arcpy.ExecuteError: 
 msgs = arcpy.GetMessages(2) 
 arcpy.AddError(msgs) 
 arcpy.AddMessage(msgs)
except:
 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])
 msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
 arcpy.AddError(pymsg)
 arcpy.AddError(msgs)
 arcpy.AddMessage(pymsg + "\n")
 arcpy.AddMessage(msgs)

Here is a screenshot of the parameter list.

enter image description here

Here is a screenshot of the messages, at least I would expect

enter image description here

asked Jun 2 at 22:56
8
  • The default embedded code does nothing just like this. Is the script embedded or pointing at a .py file on your filesystem? If you right click the tool and select edit, does the correct code show in your configured editor? Commented Jun 3 at 3:51
  • 1
    Yes, there was no code in the edit window which is odd. I added the correct script at tool creation like I have dozens of times. Yet another ArcGIS Pro bug? Feel free to post as an answer and I will accept. Commented Jun 3 at 14:41
  • Don't know if this is a red herring but I follow the coding standards of using a main() function as discussed here. Your example appears not to do this? Commented Jun 3 at 18:49
  • Thanks @Hornbydd. I am aware of main() but these geoprocessing tools a just procedural tools that are not going to me run from a command line or imported into other scripts. I always find adding extra code just complicates the code. In this case there is no value to main()? Commented Jun 3 at 20:54
  • 1
    Are you saying that this issue is resolved? If so, please post and answer and then mark it as correct. Commented Jun 6 at 1:39

1 Answer 1

1

For some unknown reason, adding a new scripting tool to the ArcGIS Pro toolbox failed to migrate the code into the tool. After using the edit option to view the Python code it was obvious the default code was added to the toolbox. Copy and pasting the code from the IDE into the toolbox tool solved the problem.

answered Jun 6 at 15:13

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.