ArcMap の基本オブジェクトへのアクセス

      2017/12/09

Public Sub Test()
    '現在のドキュメントを取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    'アクティブなデータフレームの取得
    Dim pMap As IMap
    Set pMap = pMxDocument.FocusMap
     
    'レイヤを取得
    Dim pLayer As ILayer
    Set pLayer = pMap.Layer(0)
'    Set pLayer = pMap.Layer(InputBox("Layer Index ?"))
     
    'フィーチャレイヤを取得
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pLayer
     
    'フィーチャクラスを取得
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    'フィールドのコレクションを取得
    Dim pFields As IFields
    Set pFields = pFeatureClass.Fields
     
    'フィーチャを取得
    Dim pFeature As IFeature
    Set pFeature = pFeatureClass.GetFeature(1)
'    Set pFeature = pFeatureClass.GetFeature(InputBox("ObjectID ?"))
     
    'ジオメトリを取得
    Dim pGeometry As IGeometry
    Set pGeometry = pFeature.Shape
     
    '属性値を取得
    Dim pValue As Object
    Set pValue = pFeature.Value(2)
'    Set pValue = pFeature.Value(InputBox("Field Index ?"))
'    Set pValue = pFeature.Value(pFields.FindField(InputBox("Field Name ?")))
 
End Sub

 - プログラミング, ArcGIS , ,