Call an arcpy script from C# code?

3305
2
05-29-2013 07:37 AM
KeG
by
New Contributor II
Does anyone know if it is possible to call a python script that uses the arcpy library directly from C#?
I don't want to publish a gp service because it is a royal pain in the you know what.
I just have a py script that does some geoprocessing and i want to call that from my C# code.

I can call other py scripts from C# using a shell command. But what about complex input types like Feature Set? How would i represent those as parameters to the py call?
0 Kudos
2 Replies
ModyBuchbinder
Esri Regular Contributor
Hi Ke

All data sources of ArcPy can be represented as strings as well as more complex types (sometimes).
The easiest way is to run the tool once from ArcMap and see what the strings are.
Do not load data into ArcMap so you will get the real string representation of all the data types.

Have Fun
Mody
0 Kudos
KeG
by
New Contributor II
what does the 'sometimes' apply to?
My main input param is typically Feature Set.
In the old tbx style i needed to have a dummy schema setup on this so that in C# code i could get a reference to the recordset and then load it with features from a json representation.
I don't see how this can be done without the schema in there.
Also, something makes me think that esri may have some tool that they use to load features into the feature set from a json representation, as that is how they go over the wire to the ags rest endpoint. but is that method exposed or in the black box of ags?
0 Kudos