Public Sub ShowSelectedFeatures() 'IFeatureLayerにキャスト Dim pFeatureLayer As IFeatureLayer Set pFeatureLayer = pLayer 'FeatureClassの取得 Dim pFeatureClass As IFeatureClass Set pFeatureClass = pFeatureLayer.FeatureClass Dim pFeature As IFeature 'フィーチャ選択機能にアクセス Dim pFeatureSelection As IFeatureSelection Set pFeatureSelection = pLayer 'QI(フィーチャ レイヤ) 'SelectionSetオブジェクトの取得 Dim pSelectionSet As ISelectionSet Set pSelectionSet = pFeatureSelection.SelectionSet '選択フィーチャのObjectID群を取得 Dim pEnumIDs As IEnumIDs Set pEnumIDs = pSelectionSet.IDs pEnumIDs.Reset Dim lngID As Long lngID = pEnumIDs.Next Do Until lngID = -1 Set pFeature = pFeatureClass.GetFeature(lngID) MsgBox pFeature.Fields.Field(2).Name & ":" & pFeature.Value(2) 'フィールド インデックス 2 を表示 lngID = pEnumIDs.Next Loop End Sub
選択セットの OID を取得
2016/9/1 (木)