AnsweredAssumed Answered

File doesn't exist/isn't supported - C# .NET ArcObjects Python Combo

Question asked by MollyKFoley on Feb 17, 2018
Latest reply on Feb 17, 2018 by Dan_Patterson

I have a script that is run using a combination of ArcObjects and a python script. The process starts in C# Arcobjects code, I create a geoprocessor, and then I run a toolbox tool (python script) with uploaded data from the user. The data is uploading successfully, I can see it in file explorer, however my python script says it doesn't exist. Now if I go in the python IDE, the script runs just fine there using the same file in the same location. I'm not sure what's going on.

 

This sets up the toolbox and passes the file geodatabase to the toolbox tool and runs it:

 //Set up HabitatClassification script
IGeoProcessorResult result;
IGeoProcessor2 gp = new GeoProcessor() as IGeoProcessor2;
string tlbxPath = Server.MapPath("~/ArcToolbox/HabitatMon.tbx");
gp.AddToolbox(@tlbxPath);
IVariantArray parameters = new VarArray();
parameters.Add(geodatabase);

//Run Habitat Classification script
try
{
   result = gp.Execute("HabitatClassification", parameters, null);
}

Now that I have passed the file geodatabase into the tool, in the python script, I set up the workspace and get the list of feature classes in the FGDB. It perform this step just fine, so clearly it can find the feature class I am looking for and it does, indeed, exist. 

#Get user uploaded geodatabase and set the workspace to it
uploadedGDB = sys.argv[1]
arcpy.env.workspace = uploadedGDB

#Get the patch feature class out of the geodatabase. Make sure the list created is not empty and that there
#is only one feature class within it.
patchfc = arcpy.ListFeatureClasses("*Patch*")
svyPtFC = uploadedGDB + r"\{0}".format(patchfc[0])

At this point in time, "svyPtFC" looks like this:

C:\Users\xxx\Desktop\GIS_NET_Testing\ArcObjectsTesting\ArcObjects\UploadedFiles\NETTesting.gdb_02_17_2018_11_29_23\NETTesting.gdb\Patches

 

It errors out on this line:

result = arcpy.GetCount_management(svyPtFC)

 

As a result, I get this displayed on my webpage (and you can clearly see it has the correct path the feature class displayed):

Traceback (most recent call last):


File "C:\Users\xxx\xxx\PythonProjects\HabitatClassification.py", line 300, in <module>


result = arcpy.GetCount_management(svyPtFC)


File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 17419, in GetCount


raise e


ExecuteError: Failed to execute. Parameters are not valid.


ERROR 000732: Input Rows: Dataset C:\Users\xxx\Desktop\GIS_NET_Testing\ArcObjectsTesting\ArcObjects\UploadedFiles\NETTesting.gdb_02_17_2018_11_29_23\NETTesting.gdb\Patches does not exist or is not supported


Failed to execute (GetCount).








Failed to execute (HabitatClassification).

 

 

Anybody know what's going on here? My first thought was the periods in the file path were causing an issue, but in the python IDE it goes through just fine so I'm not sure that's it.

Outcomes