ie.geologyidea.com
More

Returning feature class from Python toolbox

Returning feature class from Python toolbox


We are searching data for your request:

Forums and discussions:
Manuals and reference books:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.


I am trying to return a feature class (my sample data is a polygon fc) from a Python toolbox and cannot find any information about what I have to set to get it to work. This runs successfully and gives me a record count of 917 but in ArcCatalog in the results windowout: (and the icon looks like a table not a polygon feature class).

import arcpy class Toolbox(object): def __init__(self): self.label='BasicOutput' self.alias='BasicOutput' self.description='BasicOutput' self.summary=self.description # List of tool classes associated with this toolbox self.tools=[BasicOutput] class BasicOutput(object): def __init__(self): """Define the tool (tool name is the name of the class).""" self.label='BasicOutput' self.description='BasicOutput' self.summary=self.description def getParameterInfo(self): ps=[ arcpy.Parameter( displayName="out", name="out", datatype="GPFeatureRecordSetLayer", parameterType="Derived", direction="Output"), ] return ps def updateParameters(self,parameters): return def updateMessages(self,parameters): return def execute(self,parameters,messages): fs=arcpy.FeatureSet() fs.load(r'D:customAppsPaddockGRASPBasicOutput.gdb/Cadastre') arcpy.AddMessage('record count: %s'%arcpy.GetCount_management(fs)) parameters[0].value=fs

I will then be publishing it as a GP service in ArcGis server, but can't even get it working in ArcCatalog! Using ArcGis 10.2.1.


TLDR: Changeparameters[0].value=fstoarcpy.SetParameterAsText(0,fs)

EDIT: after some minor testing, looks likearcpy.SetParameteralso works.

EDIT2: Oops, just noticed that I also changed the datatype toDEFeatureClass.

OK, after many hours of trying various things and trawling through forums about problems that weren't the same as mine or about getting features as input instead of output, I stumbled on the simple solution (yet completely unintuitive to me). Despite the name of the functionSetParameterAsText, it actually sets the return value to my feature class - returns the path in ArcCatalog which I can copy features from and returns JSON when published as a GPService.



Comments:

  1. Russel

    maybe I'll just shut up

  2. Mabei

    I fully share your opinion. This is a good idea. I support you.

  3. Zotikos

    But where the logic?

  4. Goltik

    Excuse, topic has mixed. It is removed



Write a message