1

I am following the sample code from ESRI for checking topology errors using vb.net. But in my workspace an error happened. My code is listed below:

   ' Step 1 - access a topology
    Dim topoUiD As UID = New UIDClass
    topoUiD.Value = "esriEditorExt.TopologyExtension"
    Dim m_application As IApplication = My.ArcMap.Application
    Dim topologyExt As ITopologyExtension = CType(m_application.FindExtensionByCLSID(topoUiD), ITopologyExtension)  'original code from esri
    Dim topology As ITopology
    topology = CType(topologyExt.CurrentTopology, ITopology)

    ' Step 2 - Finding topology errors
    Dim geoDS As IGeoDataset = CType(topology, IGeoDataset)
    Dim errorContainer As IErrorFeatureContainer = CType(topology, IErrorFeatureContainer)
    Dim eErrorFeat As IEnumTopologyErrorFeature
    eErrorFeat = errorContainer.ErrorFeaturesByRuleType(geoDS.SpatialReference, esriTopologyRuleType.esriTRTLineCoveredByLineClass, Nothing, True, False)
    Dim topoError As ITopologyErrorFeature

    topoError = eErrorFeat.Next

    ' Step 3 - selecting topology errors
    topologyExt.ClearActiveErrors(esriTEEventHint.esriTENone)
    topologyExt.DelayEvents(True)

    While Not ((topoError = eErrorFeat.Next) Is Nothing)
        topologyExt.AddActiveError(topoError, esriTEEventHint.esriTENone)
    End While

    topologyExt.DelayEvents(False)

In the while sentence: While Not ((topoError = eErrorFeat.Next) Is Nothing)

An error indicates:

Operator '=' is not defined for types 'ESRI.ArcGIS.Geodatabase.ITopologyErrorFeature' and 'ESRI.Geodatabase.ITopologyErrorFeature'. Use 'Is' operator to compare two reference types.

When I change "=" to "Is", another error indicates:

'Is' operator does not accept operands of Type 'Boolean'. Operands must be reference or nullable types.

So I don't know how to define the equals operator of 2 'ESRI.ArcGIS.Geodatabase.ITopologyErrorFeature'. Thanks in advance.

2

Try this syntax:

topoError = eErrorFeat.Next
Do While Not (topoError Is Nothing)
    topologyExt.AddActiveError(topoError, esriTEEventHint.esriTENone)
    topoError = eErrorFeat.Next
Loop

You may want to confirm that eErrorFeat is not actually Nothing?

  • Hi Hornbydd, thanks. in fact I want to get the topology error list. – ppLily Aug 11 '14 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.