Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I’m trying to write a code, which will find the features, which have an override on the offset field. It is very easy to find if a feature has any override, but to find if a feature has an override on specific Geometric effect probably needs absolutely different approach.

Here is my code: Public Sub RepClass() On Error GoTo ErrorHandler

    Dim pMap As IMap
    Dim pActiveView As IActiveView
    Dim pEnumLayer As IEnumLayer
    Dim pLayer As ILayer
    Dim pFeatureSelection As IFeatureSelection = Nothing
    Dim pFSelLayerObalkaZR As IFeatureSelection = Nothing
    Dim pFeatureLayerML As IFeatureLayer = Nothing
    Dim pFeatureLayerZKomOBjektB As IFeatureLayer = Nothing
    Dim pFeatureClass As IFeatureClass = Nothing

    pMxDocument = m_application.Document

    pMap = pMxDocument.FocusMap

    pActiveView = pMxDocument.FocusMap


    'Go through all layers in map document
    pEnumLayer = pMap.Layers

    pLayer = pEnumLayer.Next
    Do Until pLayer Is Nothing
        If TypeOf pLayer Is IFeatureLayer Then
            'Find the right layer
            If pLayer.Name = "Z_KomObjekt_L" Then
                'MsgBox("Tady 2 " & pLayer.Name, MsgBoxStyle.OkOnly)
                pFeatureLayerZKomOBjektB = pLayer
                'MsgBox("Tady 2 " & pLayer.Name, MsgBoxStyle.OkOnly)
                pFeatureClass = pFeatureLayerZKomOBjektB.FeatureClass
                MsgBox(pFeatureClass.AliasName & " nalezen", MsgBoxStyle.OkOnly)
                Exit Do
            End If
        End If
        pLayer = pEnumLayer.Next
    Loop
    pEnumLayer.Reset()
    'Exit if not a line  feature class
    If Not pFeatureClass.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline Then
        MsgBox("Shape type must be a Point")
        Exit Sub
    End If

    Dim pRWE As IRepresentationWorkspaceExtension
    Dim pRepClass As IRepresentationClass
    Dim pRepresentationRule As IRepresentationRule = Nothing
    Dim pRepresentationRules As IRepresentationRules
    Dim pRepRuleInit As IRepresentationRuleInit
   Dim lCircleID As Long
    Dim pDiamond As ISimpleMarkerSymbol
    Dim lDiamondID As Long
    Dim pQueryFilter As IQueryFilter
    Dim pFCursor As IFeatureCursor
    Dim lSymFieldIndex As Long
    Dim i As Long
    Dim pFeature As IFeature

    'MsgBox("OK")
    pRWE = GetRepWSExtFromFClass(pFeatureClass)  'Function that returns a reference to RepresentationWorkspaceExtension

    pRepClass = pRWE.OpenRepresentationClass("ZM50_Z_KomObjekt_L") 'Representation Class belonging to feature  layer
    pRepresentationRules = pRepClass.RepresentationRules


    Dim pQFilter As IQueryFilter
    pQFilter = New QueryFilter
    pQFilter.WhereClause = ""

    Dim pFeatureCursor As IFeatureCursor
    Dim pMapContext As IMapContext
    Dim pDisplay As IDisplayTransformation
    Dim pRepresentation As IRepresentation
    Dim pOverride As IOverride
    Dim pGraphicAttributes As IGraphicAttributes = Nothing
    Dim iIndex2 As Integer
    Dim iNumberOfRepLayers As Integer
    Dim pGeometricEffects As IGeometricEffects = Nothing
    Dim pGeometricEffect As IGeometricEffect
    Dim pBasicLineSymbol As IBasicLineSymbol
    'Dim pGeometry As IGeometry = Nothing
    'Dim pRepRule As IRepresentationRule = Nothing

    pMapContext = New MapContext
    pDisplay = pMxDocument.ActiveView.ScreenDisplay.DisplayTransformation
    pMapContext.InitFromDisplay(pDisplay)
    pFeatureCursor = pFeatureLayerZKomOBjektB.Search(pQFilter, False)
    pFeature = pFeatureCursor.NextFeature
    Do Until pFeature Is Nothing
        pRepresentation = pRepClass.GetRepresentation(pFeature, pMapContext)
        pOverride = pRepClass.GetRepresentation(pFeature, pMapContext)
        If pOverride.HasAttributeOverride = True Then
            MsgBox("Feature " & pFeature.OID & " has an override")
        Else
            MsgBox("Feature " & pFeature.OID & " hasn not an override")
        End If

        AND HERE I’M LOST, I DON’T KNOW WHAT TO DO NEXT, NEXT LINES ARE ONLY SHOOTS IN THE DARK
        'Find what rule a feature has
        If pRepresentation.RuleID = 62 Then
            MsgBox("RuleId is 62")
            pRepresentationRule = pRepresentationRules.Rule(62)

        ElseIf pRepresentation.RuleID = 64 Then
            MsgBox("RuleId is 64")
            pRepresentationRule = pRepresentationRules.Rule(64)
            iNumberOfRepLayers = pRepresentationRule.LayerCount
            MsgBox("Number of layers in RepRule " & iNumberOfRepLayers)

            If TypeOf pRepresentationRule.Layer(0) Is IBasicLineSymbol Then


                Dim pStroke As ILineStroke
                'pBasicLineSymbol = New BasicLineSymbol
                pBasicLineSymbol = pRepresentationRule.Layer(0)
                pStroke = pBasicLineSymbol.Stroke
                pGraphicAttributes = pStroke
            End If

        End If

        pFeature = pFeatureCursor.NextFeature
    Loop

ErrorHandler: MsgBox(Err.Description, vbInformation, "CreateRepresentationClass") End Sub

'GetRepWSExtFromFClass is a function that takes a reference to a FeatureClass and returns the RepresentationWorkspaceExtension

Public Function GetRepWSExtFromFClass(ByVal pFClass As IFeatureClass) As IRepresentationWorkspaceExtension 'Get RepresentationWorkspaceExtension from Feature Class On Error GoTo ErrorHandler Dim pDataset As IDataset Dim pWorkspace As IWorkspace Dim pExtManager As IWorkspaceExtensionManager Dim pUID As IUID

    pDataset = pFClass
    pWorkspace = pDataset.Workspace
    pExtManager = pWorkspace
    pUID = New UID
    pUID.Value = "{FD05270A-8E0B-4823-9DEE-F149347C32B6}"
    GetRepWSExtFromFClass = pExtManager.FindExtension(pUID)

    Exit Function

ErrorHandler: MsgBox(Err.Description, vbInformation, "GetRepWSExtFromFClass") End Function

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.