\cat gis, arcgis, programming
Private Sub UIButtonControl1_Click() Dim pApp As IApplication Dim pMxDoc As IMxDocument Dim pMap As IMap Dim pEnumLayer As IEnumLayer Dim pLayer As ILayer Dim pLayers() As ILayer Dim i As Integer Dim pListDlg As IListDialog Dim boolOK As Boolean Dim pRasterLayer As IRasterLayer Dim pRaster As IRaster Set pApp = Application Set pMxDoc = ThisDocument Set pMap = pMxDoc.FocusMap i = 0 ReDim pLayers(pMap.LayerCount) Set pEnumLayer = pMap.Layers Set pLayer = pEnumLayer.Next Set pListDlg = New ListDialog pEnumLayer.Reset Do While Not pLayer Is Nothing If TypeOf pLayer Is IRasterLayer Then pListDlg.AddString pLayer.Name Set pLayers(i) = pLayer i = 1 End If Set pLayer = pEnumLayer.Next Loop If i = 0 Then Exit Sub End If boolOK = pListDlg.DoModal("Choose a DEM", 0, pApp.hWnd) If boolOK = False Then Exit Sub End If Set pLayer = pLayers(pListDlg.Choice) Set pRasterLayer = pLayer MsgBox pRasterLayer.Name End Sub
Private Sub UIButtonControl1_Click() Dim pD As IMxDocument Set pD = Application.Document Dim pM As IMap Set pM = pD.FocusMap Dim pFL As IFeatureLayer Set pFL = pM.Layer(0) Dim pFCur As IFeatureCursor Set pFCur = pFL.FeatureClass.Search(Nothing, False) Dim pF As IFeature Set pF = pFCur.NextFeature Dim pA As IArea Do Until pF Is Nothing Set pA = pF.Shape pF.Value(pF.Fields.FindField("Area")) = pA.Area pF.Store Set pF = pFCur.NextFeature Loop End Sub