PROBLEM
If a source feature has zero length, the Simple Data Loader (Load Data in ArcCatalog) will load it and not report an error. The feature will not display, but will show up in the attribute table.A zero length line feature usually is a data problem.
Rather than report an error the Simple Data Loader is inserting a null shape.
Code:
Public Sub Select_NonNulls()
Dim pMXd As IMxDocument
Set pMXd = ThisDocument
Dim pMap As IMap
Set pMap = pMXd.FocusMap
'-- Make sure there is a selected layer in map
If pMXd.SelectedItem Is Nothing Then
MsgBox "Must have a selected item in map"
Exit Sub
End If
If Not TypeOf pMXd.SelectedItem Is IFeatureLayer Then
MsgBox "The selected item must be a layer"
Exit Sub
End If
Dim pDispTab As IDisplayTable
Set pDispTab = pMXd.SelectedItem
'-- Create an empty selectionset and open a feature cursor
Dim pFCursor As IFeatureCursor
Dim pSelSet As ISelectionSet
Dim pTable As ITable
Dim pFeatCls As IFeatureClass
Dim pFeat As IFeature
Set pTable = pDispTab.DisplayTable
Set pSelSet = pTable.Select(Nothing, esriSelectionTypeHybrid, _
esriSelectionOptionEmpty, Nothing)
Set pFeatCls = pTable
Set pFCursor = pFeatCls.Search(Nothing, False)
'-- Add all features that are not null to the selection set
Set pFeat = pFCursor.NextFeature
Do While (Not pFeat Is Nothing)
If Not pFeat.Shape Is Nothing Then
If Not pFeat.Shape.IsEmpty Then
If pFeat.HasOID Then
pSelSet.Add pFeat.OID
End If
End If
End If
Set pFeat = pFCursor.NextFeature
Loop
'-- Apply the selectionset to the layer
Dim pActiveView As IActiveView
Dim pFeatSel As IFeatureSelection
Set pActiveView = pMap
Set pFeatSel = pDispTab
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
Set pFeatSel.SelectionSet = pSelSet
pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing
End Sub
Article ID:000003201
Get help from ArcGIS experts
Download the Esri Support App