Friday 27 April 2018

arcpy - Using GPFeatureRecordSetLayer in Python Toolbox for ArcMap?


I have written a Python Toolbox for ArcMap, that allows a user to consume a Template Feature Layer to run through a series of processes.


The user defines an Area of Interest (AOI) in the Tool and then a bunch of Geoprocessing Tools run for this AOI.


I have tested the Tool in ArcMap 10.4 and 10.6 and it works as expected. I asked a user to run it in 10.2 and he produced a result.


I have however managed to get access to two Desktops running 10.2 and the AOI is not displayed correctly.


The Tool is meant to look like this:


enter image description here


When I open the tool in 10.2, in place of the "Tool:: Select your Area of Interest" there is a path to an "in_memory" workspace...of which I have none in my script at all:


enter image description here


Has the way in which the "GPFeatureRecordSetLayer" data type changed between ArcMap 10.2 and 10.4?



I think we should ignore the one time it worked on a 10.2 machine, as I was not there to witness the exact steps taken by the user, and the tool may have run correctly, without the AOI being created - it may have run using information already stored in the AOI Template file.


My code to create this tool is below:


**def getParameterInfo(self):
'''parameter definitions for GUI'''
params = None
param0 = arcpy.Parameter(
displayName = "AOI",
name = "Choose you Area of Interest",
datatype = "GPFeatureRecordSetLayer",
parameterType = "Required",

direction = "Input")

param0.value = r"C:\Data\AOI.lyr"

param1 = arcpy.Parameter(
displayName = "Project Name",
name = "Please provide a project for this search",
datatype = "GPString",
parameterType = "Required",
direction = "Input")


param1.value = "Input Text"

param2 = arcpy.Parameter(
displayName = "Project Identifier",
name = "Please provide an unique identifer for this search - Text Only",
datatype = "GPString",
parameterType = "Required",
direction = "Input")


param2.value = "Input Text"

params = [param0 , param1, param2]
return params**

Answer



After much backwards and forwards with ESRI I have an answer:


The issue is the "GPFeatureRecordSetLayer" in 10.2.x It is a bug which was fixed in subsequent releases. The result of which, because 10.2 is in Mature Support, there is no avenue to fix the bug. So there is no solution, other than finding a new workflow.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...