Hi all,
I created a custom script which I also converted into a GP tool within ArcGIS pro. When I try to feed lists into this tool as input parameters in ArcGIS Notebooks it fails and provides generic error messages. The same tool works in Notebooks if I am to use a single field rather than a field list.
Here is my code -
toolbox = "C:\\Users\\Kedaravindan Bhaskar\\Documents\\ArcGIS\\Projects\\FBM_research\\FBTool\\firebreak.tbx"
arcpy.ImportToolbox(toolbox, "firebreak")
arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', 'DirNWL_Class_DirNWL', 'PT1_P_DirNWL_Slope_Type', 'PT1_P_DirNWL_Slope', 'DirNWL_FRD_DirNWL', 'buffer') # Here the tool runs successfuly
import arcpy
# Use arcpy.ListFields() to list fields in a feature class
Classfields = arcpy.ListFields('SusBui_Point_CopyFeatures', '*Class*', 'TEXT')
# Iterate over the fields and print their names
for field in Classfields:
print(field.name)
# Use arcpy.ListFields() to list fields in a feature class
SlopeVfields = arcpy.ListFields('SusBui_Point_CopyFeatures', '*Slope', 'FLOAT')
# Iterate over the fields and print their names
for field in SlopeVfields:
print(field.name)
# Use arcpy.ListFields() to list fields in a feature class
SlopeTfields = arcpy.ListFields('SusBui_Point_CopyFeatures', '*Slope_Type', 'TEXT')
# Iterate over the fields and print their names
for field in SlopeTfields:
print(field.name)
import arcpy
# Use arcpy.ListFields() to list fields in a feature class containing 'frd'
FRDfields = arcpy.ListFields('SusBui_Point_CopyFeatures', '*FRD*')
# Iterate over the fields and print their names
for field in FRDfields:
print(field.name)
arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', Classfields , SlopeTfields, SlopeVfields, FRDfields, 'buffer')
#### ERROR MESSAGE
RuntimeError Traceback (most recent call last)
In [26]:
Line 1: arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', Classfields , SlopeTfields, SlopeVfields, FRDfields, 'buffer')
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 38: validation is performed. This method is called whenever a parameter
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 35:
File C:\Users\Kedaravindan Bhaskar\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 520: return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
Nothing seems awry with the field names and types that are inputted into the tool so I am struggling to understand why this is happening. The error message is also quite generic.
I will also edit the 'buffer' (which is an output param) to do some form of inline variable substitution so multiple fields are populated but that shouldn't cause the issue at hand IMO.
My only thought is maybe I need to edit the script to accept lists??
Any idea what might be going wrong? Your help would be greatly appreciated : )
Please let me know if there is anything else I can do
Warm regards, Kedar
Kedar,
Is your custom GP tool set up to accept multi-value entries for the fields parameter. If it's only expecting a single entry of type "field" and you provide it with a list then it's going to get confused.
Hi Richard,
Thanks for your response. No I hadn't done this initially but now I have by navigating to the tool > properties > parameters > data type > then checking the multiple values box (see attached photo at the end), but still the same error message is produced. I did this only for the parameters where I would feed in multi-values.
RuntimeError Traceback (most recent call last)
In [62]:
Line 1: arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', Classfields , SlopeTfields, SlopeVfields, FRDfields, 'buffer')
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 38: validation is performed. This method is called whenever a parameter
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 35:
File C:\Users\Kedaravindan Bhaskar\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 520: return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
Do I need to edit something within the script itself? Or am I missing something else?
Warm regards, Kedar
So inputs 2,3,4 and 5 are all setup to accept multiple values now? Because even if you know your listFields action on your script will only return a single field, you are still returning it as a list so the input to the next step will need to be for multiple values.
I think input 6 should not accept multiple values as you're only inputting 'buffer' so unless that is a list object rather than just a field name then that should just be a normal field input.
Hi Richard,
Sorry, there was a mistake in the tool params, here is the corrected version -
As you can see I want Input features and Vegetation_Type to be fixed. Everything else is inputted as a list and buffer/outField is the output (which should produce multiple fields). I changed this yet I continued to get the same error message -
RuntimeError Traceback (most recent call last)
In [29]:
Line 1: arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', Classfields , SlopeTfields, SlopeVfields, FRDfields, 'outfield')
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 40: return
File C:\Users\Kedaravindan Bhaskar\Documents\ArcGIS\Projects\FBM_research\FBTool\firebreak.tbx, in FBCalc:
Line 37: """Modify the values and properties of parameters before internal
File C:\Users\Kedaravindan Bhaskar\AppData\Local\Programs\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 520: return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Object: Error in executing tool
Here is the code - (note that I also tried this code after changing buffer to a single field output in the tool parameters, but still, the same error message appears)
arcpy.FBCalc_firebreak('SusBui_Point_CopyFeatures', 'SusBui_Point_VEGCODE', Classfields , SlopeTfields, SlopeVfields, FRDfields, 'outfield')
Hope this can clarify my issue. Thank you so much.
Warm regards, Kedar
Hello,
I'm still not able to get the tool working with lists. Any update would be greatly appreciated.
Warm regards, Kedar
Kedar,
Short of playing with the actual tool and script I'm not sure I can debug it much further. If you're willing to share it and a data sample I can have a look
Hi Richard,
Thank you for your response and sorry that I am late in responding.
Unfortunately we plan to publish this project so I can't share the data. Thank you so much for your help till now. I will post the solution when we figure it out.
Regards, Kedar