フィーチャに設定されているシンボルの参照を取得してプロパティを更新

 2016/9/1 (木)    

'フィーチャに設定されているシンボルの参照を取得してプロパティを更新
Public Sub subChangeSymbolProperty()
    'ThisDocumentの取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    'アクティブなデータフレームの取得
    Dim pMap As IMap
    Set pMap = pMxDocument.FocusMap
     
    '最上位レイヤの取得
    Dim pLayer As ILayer
    Set pLayer = pMap.Layer(0)
 
    '特定フィーチャの取得
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pLayer  'QI
     
    'フィーチャクラスの取得
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    '特定フィーチャ
    Dim pFeature As IFeature
    Set pFeature = pFeatureClass.GetFeature(3966)
     
     
    'レンダラの変更
    Dim pGeoFeatureLayer As IGeoFeatureLayer
    Set pGeoFeatureLayer = pLayer   'QI
     
    Dim pLookupSymbol As ILookupSymbol
    Set pLookupSymbol = pGeoFeatureLayer.Renderer
     
    '対象フィーチャの使用しているシンボルを取得
    Dim pMultiLayerMarkerSymbol As IMultiLayerMarkerSymbol
    Dim pSimpleMarkerSymbol As ISimpleMarkerSymbol
     
    'シンボルがMultiLayerかそうでないかを判断
    If TypeOf pLookupSymbol.LookupSymbol(True, pFeature) Is IMultiLayerMarkerSymbol Then
        Set pMultiLayerMarkerSymbol = pLookupSymbol.LookupSymbol(True, pFeature)
        Set pSimpleMarkerSymbol = pMultiLayerMarkerSymbol.Layer(0)
         
    Else
        Set pSimpleMarkerSymbol = pLookupSymbol.LookupSymbol(True, pFeature)
         
    End If
     
    '取得したシンボルの色を変更
    Dim pRGB As IRgbColor
    Set pRGB = New RgbColor
     
    pRGB.RGB = vbRed
    pSimpleMarkerSymbol.Color = pRGB
     
    'TOC,マップの再描画
    pMxDocument.UpdateContents
    pMxDocument.ActiveView.Refresh
     
End Sub

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.