Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Parameters for DeleteIdentical geoprocessing tool from vb.net

$
0
0
Hi all,
I'm trying to run DeleteIdentical geoprocessing tool from a piece of VB.net code, but I just get an error message:
Excepción del tipo 'System.Runtime.InteropServices.COMException' en ESRI.ArcGIS.Geoprocessor.dll
ERROR 000622: Failed to execute (Delete Identical). Parameters are not valid.
ERROR 000620: Input to parameter fields cannot be represented as a string.
I know it's because of the parameter types.
Which is the right ArcObjects class I should use for parameter types 'Table View' and 'Field'??

My code:

Private Sub unicos()
Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
Try
Dim table As Geodatabase.Table = GetTable("C:\Users\cfraile\INSPE.shp")
Dim fields() As Geodatabase.Field = GetField("C:\Users\cfraile\INSPE.shp", "Shape")

Dim deldupTool As New DataManagementTools.DeleteIdentical(table, fields)
GP.Execute(deldupTool, Nothing)

Catch ex As Exception
Dim sev As Object = 2
Debug.Print(GP.GetMessages(sev))
End Try
End Sub

Private Function GetTable(ByVal fullShapeFile As String) As Geodatabase.Table

Dim pWorkspaceFactory As IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory
Dim pFWS As IFeatureWorkspace = pWorkspaceFactory.OpenFromFile(IO.Path.GetDirectoryName(fullShapeFile), 0)
Dim pfeatClass As IFeatureClass = pFWS.OpenFeatureClass(IO.Path.GetFileNameWithoutExtension(fullShapeFile))

Dim ptab As Geodatabase.Table = pfeatClass
Return ptab

End Function

Private Function GetField(ByVal fullShapeFile As String, fieldName as String) As Geodatabase.Field()

Dim pWorkspaceFactory As IWorkspaceFactory = New ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory
Dim pFWS As IFeatureWorkspace = pWorkspaceFactory.OpenFromFile(IO.Path.GetDirectoryName(fullShapeFile), 0)
Dim pfeatClass As IFeatureClass = pFWS.OpenFeatureClass(IO.Path.GetFileNameWithoutExtension(fullShapeFile))

Dim aField(0) As Geodatabase.Field
aField(0) = pfeatClass.Fields.Field(pfeatClass.Fields.FindField(fieldName))
Return aField

End Function
Thanks in advance!!

Viewing all articles
Browse latest Browse all 1374

Trending Articles