ArcObjects (идентификация объекта)
Добавлено: 01 окт 2008, 14:00
Помогите, пожалуйста!!! Как при помощи VBA и COM библиотек ArcObjects определить к какому слою относится выбранный объект 

Геоинформационные системы (ГИС) и Дистанционное зондирование Земли
https://gis-lab.info/forum/
Код: Выделить всё
Private Sub tool_selection_MouseDown(ByVal button As Long, _
ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pMxApp As IMxApplication
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pIdentify As IIdentify
Dim pPoint As IPoint
Dim pIDArray As IArray
Dim pFeatIdObj As IFeatureIdentifyObj
Dim pIdObj As IIdentifyObj
Dim pFeature As IFeature
Dim pField As IField
Dim i As Integer
Dim pRowObj As IRowIdentifyObject
Set pMxApp = Application
Set pDoc = Application.Document
Set pMap = pDoc.FocusMap
' ищет определяемый (нужный) слой
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).Name = "breach_features" Then
Set pIdentify = pMap.Layer(i)
End If
Next
Set pPoint = pMxApp.Display.DisplayTransformation.ToMapPoint(x, y)
Dim searchdistance As Long
searchdistance = pDoc.ActiveView.Extent.Width * 0.005
Dim pSegColl As ISegmentCollection
Set pSegColl = New Polygon
pSegColl.SetCircle pPoint, searchdistance
Dim pGeom As IGeometry
Set pGeom = pSegColl
Set pIDArray = pIdentify.Identify(pGeom)
If Not pIDArray Is Nothing Then
Set pFeatIdObj = pIDArray.Element(0)
Set pIdObj = pFeatIdObj
Set pRowObj = pFeatIdObj
Set pFeature = pRowObj.Row
pIdObj.Flash pMxApp.Display
MsgBox "Слой:" & pIdObj.Layer.Name & vbNewLine & "Feature:" & pIdObj.Name
Else
MsgBox " НЕ ТУДА Жмешь!!!!"
End If
End Sub