Geoprocessing with Geometry

443
2
03-23-2018 09:10 AM
AbelPerez
Occasional Contributor III

I am struggling to get an GP tool to work with Geometry. 

What I do is create an IPolygon object through .NET code. All that works great except sometimes the results have slivers. So it looks like the Integrate tool could help me here. Again I have an IPolygon object and am not creating any feature classes on disk. I will draw the polygon to the screen and that is it.

So I try this:

'use the Integrate tool to get rid of slivers
Dim gp As Geoprocessor = New Geoprocessor
gp.OverwriteOutput = True
gp.AddOutputsToMap = False
Dim intgGeom As Integrate = New Integrate
intgGeom.in_features = pClonePolygon 'the input polygon
intgGeom.cluster_tolerance = "2 Meters" 'set the XYTolerance to 2 Meters
gp.Execute(intgGeom, Nothing)

No cigar. I get this exception:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in ESRI.ArcGIS.Geoprocessor.dll
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

According to this help page all GP tools should work with geometry: Using geometry objects with geoprocessing tools—Help | ArcGIS Desktop So what am I doing wrong here?

~AGP

0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor

I experimented with some code and I too get an error when I supply a single polygon geometry. It does not error if I supply a FeatureLayer but it did crash! I think this is a tool that can only accept a dataset despite what the help file says.

0 Kudos
AbelPerez
Occasional Contributor III

I also tried an in-memory feature class and that crashes with a COM exception.

0 Kudos