Thanks for any and all replies in advance!
I am trying to create python script tool that uses the merge tool but I am having issues getting the field map to show and populate as I add features. As of now, it won't even populate. However, if I recreate this using ModelBuilder, it works as intended. I am starting to think I need to get into Tool Validation.
Here is the part I am having issues with:
import arcpy
#input features. Set output for merge
polygonsToUse = arcpy.GetParameterAsText(0)
mergedPolygons = arcpy.GetParameterAsText(1)
#get field map so user can remove unneccessary fields
fieldMap = arcpy.GetParameterAsText(2)
#merge polygons
arcpy.Merge(polygonsToUse,mergedPolygons,fieldMap)
and here is a screenshot of my script tool parameter setup:
Thank you!
try 'derived from' instead of optional (or is it direction?). I suspect optional ignores if the combo isn't actually selected/changed.
Thanks Dan! Unfortunately that doesn't seem to work. When I change to derived, the Output Field Map parameter no longer shows up. I actually copied the script tool parameter setup from the merge tool to verify I had the correct settings for each (right-click Merge tool, then properties).
I've started looking at python tool validation(Customizing tool behavior in a Python toolbox—Geoprocessing and Python | Documentation) and found another post that talks about this (arcgis 10.5 - Creating Field Mapping Parameter in Arcpy Script - Geographic Information Systems Stac... )
I guess after looking into validation, I am wondering what the validation settings are for the Merge tool itself. When you look at it's properties, that does not show up. Creating this same tool in model builder works just fine so that tells me one of the tools, or model builder has built in validation somewhere.
Hello Ford,
What version of ArcGIS Pro are you working with? Could you share a screeshot of how your script tool looks like when opened in Pro (see example below)?
Regards,
Josphat
Hi Josphat!
I am now going between ArcGIS Pro 2.4.3 and 2.3.2. After playing with it some more, I've noticed in 2.4.3 the field map will populate as the script is written currently, but only with the first feature it is given. If more than one feature is supplied for polygons, you have to click the Reset button to refresh the output fields. In 2.3.2 none of this happens.
In 2.4.3:
In 2.3.2:
The reset button updates the last saved settings. So this is the expected behavior.
Hello Robert,
I hope you are all set now? Please let us know if you have any additional questions.
Josphat.