Select to view content in your preferred language

Feature Set parameter in a tool destined to be a gp service

2767
4
10-25-2012 01:36 PM
KevinGooss
Regular Contributor
I'm converting some 10.0 python code into a 10.1 python toolbox.
One of my parameters is a Feature Set.
in my 10.0 code if i run this in arcmap i get the interactive buttons to digitize a shape
in 10.1 i don't get this option. i just get the layers in the map or a folder icon to load other layers.

I think this has something to do with the schema. this is an input parameter.
in 10.0 world i would have used catalog to point this tool at a dummy schema just to get it stubbed out.

At 10.1 i think it is supposed to work differently but i can't figure it out and i don't see enough in the docs to help me.
there is alot of stuff in the docs about schema for output fs params, mine is input.
i want to serve this script as a gp tool in ags. the app would upload features in a format that the fs param can understand.

i saw something in the doc about needing geometryType and fieldRule params but i could use a working code sample.
here is what i have thus far (this is in a python toolbox):

class TestTool(object):
    def __init__(self):
        self.label = "TestTool"
        self.description = "TestTool"
        self.canRunInBackground = False

    def getParameterInfo(self):
        #Feature Set you pick a layer or load a layer
        param0 = arcpy.Parameter(
        displayName="aFeatureSet",
        name="aFeatureSet",
        datatype="Feature Set",
        parameterType="Required",
        direction="Input")
        #param0.value = ""

        param1 = arcpy.Parameter(
        displayName="aString",
        name="aString",
        datatype="String",
        parameterType="Required",
        direction="Input")
        param1.value = ""


        params = [param0, param1]
        return params

    def isLicensed(self):
        return True

    def updateParameters(self, parameters):
        return

    def updateMessages(self, parameters):
        return

    def execute(self, parameters, messages):
        #do stuff
Tags (2)
0 Kudos
4 Replies
KevinHibma
Esri Regular Contributor
Almost there....just need to assign the template to the value.

    #Feature Set you pick a layer or load a layer
        param0 = arcpy.Parameter(
        displayName="aFeatureSet",
        name="aFeatureSet",
        datatype="Feature Set",
        parameterType="Required",
        direction="Input")
        param0.value = "c:\\mytemplates\\line.shp"
        #or
        #param0.value =  os.path.join(os.path.dirname(__file__), "f.gdb\\line")
0 Kudos
KevinGooss
Regular Contributor
I just noticed that in the docs after i posted. I used a lyr file and now in arcmap i do see the new feature template so i am able to digitize in arcmap, so that's cool.
but when i publish the tool and send it a feature via the rest interface i get an error:

Unable to complete operation.
The workspace is not connected.


I really don't need any of the schema i'm simply sending in coordinate sets for a polygon. I'm using that in the tool to do an intersection and then return a specific string out of the tool. Is the feature set overkill for what i need?

I'm publishing from my ags web manager machine over to my ArcServer machine by creating a disconnected sd file. Maybe something isn't being copied during the publish process properly?
0 Kudos
KevinHibma
Esri Regular Contributor
Well a featureset takes a certain input. So I'd use whatever you have your coordinates in. If thats something which featureset can read, then go with that. If its a "string", like [[2,2], [5,5]] then use the string control.

I sort of understand what you're doing, but without the complete picture I can't offer a "best suggestion". My guess though is you probably have formatted json that you're passing in so you should be using the featureset control?
0 Kudos
KevinGooss
Regular Contributor
yeah, its json that the js api creates when a user digitizes within my app.
now that the rest endpoint has the schema (via the value in python) it fills in all of that for me when i go to the execute method.
it leaves the features as a [] so that i can drop my geometry representation in there.
I don't put in any attributes because this is just a sketch the user makes and the script is to validate that the geometry is acceptable before dumping it in.
I suppose i could trim my schema down to have the bare attributes rather than those of the target feature class that the feature is destined for.
I'll give that a try and see how it shakes out. I'm not interested in attributes for this gp tool, just want the geometry.
0 Kudos