YouTube | Facebook | X(Twitter) | RSS

リレート フィーチャの取得

2016/9/1 (木)

IRelationshipClassCollection pRelationshipClassCollection = pLayer;
IEnumRelationshipClass pEnumRelationshipClass = pRelationshipClassCollection.RelationshipClasses;
pEnumRelationshipClass.Reset();
 
IRelationshipClass pRelationshipClass = pEnumRelationshipClass.Next();
ISet pSet1 = pRelationshipClass.GetObjectsRelatedToObject(pFeature); //pFeatureはリレート元のフィーチャ
pSet1.Reset();
 
IFeature pFeature1 = pSet1.Next();
Dim pRelationshipClassCollection As IRelationshipClassCollection = pLayer
Dim pEnumRelationshipClass As IEnumRelationshipClass = pRelationshipClassCollection.RelationshipClasses
pEnumRelationshipClass.Reset()
 
Dim pRelationshipClass As IRelationshipClass = pEnumRelationshipClass.Next()
Dim pSet1 As ISet = pRelationshipClass.GetObjectsRelatedToObject(pFeature) 'pFeatureはリレート元のフィーチャ
pSet1.Reset()
 
Dim pFeature1 As IFeature = pSet1.Next()
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(1)
'    Set pLayer = pMap.Layer(InputBox("Layer Index ?"))
     
    'フィーチャレイヤを取得
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pLayer
     
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    Dim pFeature As IFeature
    Set pFeature = pFeatureClass.GetFeature(2)
    Debug.Print pFeature.Value(3)
 
     
     
    Dim pRelationshipClassCollection As IRelationshipClassCollection
    Set pRelationshipClassCollection = pLayer
   
    Dim pEnumRelationshipClass As IEnumRelationshipClass
    Set pEnumRelationshipClass = pRelationshipClassCollection.RelationshipClasses
    pEnumRelationshipClass.Reset
     
    Dim pRelationshipClass As IRelationshipClass
    Set pRelationshipClass = pEnumRelationshipClass.Next
     
    Dim pSet1 As ISet
    Set pSet1 = pRelationshipClass.GetObjectsRelatedToObject(pFeature)
    pSet1.Reset
     
    Dim pFeature1 As IFeature
    Set pFeature1 = pSet1.Next
     
    Debug.Print pFeature1.Value(3)
 
End Sub
  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『"地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

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