dsheehan@mit.edu

what does IEnumlayer return?

Discussion created by dsheehan@mit.edu on May 21, 2011
Hi,

I want to find all raster layers in my map.  I use this code:


            Dim pLayer As ESRI.ArcGIS.Carto.ILayer
            Dim CurrentLayer As ESRI.ArcGIS.Carto.ILayer
            Dim pId As New ESRI.ArcGIS.esriSystem.UID
            pId.Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}"
            pEnumLayer = m_pMap_l.Layers(pId, True)
            pEnumLayer.Reset()
            GetDEM.Items.Clear()
            GlobalVars.LikelyDem = "select one"

            pLayer = pEnumLayer.Next
            Dim DEMtest As ESRI.ArcGIS.Carto.IRasterLayer
            DEMtest = New ESRI.ArcGIS.Carto.RasterLayer
            Do While Not pLayer Is Nothing
                MsgBox(pLayer.GetType.Name)
                MsgBox(DEMtest.GetType.FullName)
                If pLayer.GetType Is DEMtest.GetType Then
                    GetDEM.Items.Add(pLayer.Name)
                End If
                If pLayer.Name Like "*DEM*" Or pLayer.Name Like "*dem*" Then
                    GlobalVars.LikelyDem = pLayer.Name
                End If
                pLayer = pEnumLayer.Next
            Loop

The type I am comparing the current layer to is reasonable (and is what it is defined as) while the current layer is always typed as a COM object rather than a type of layer.  This is a rebuilt version from VB6 and doesn't do at all what I want it to do.  Any suggestions?

Daniel

Outcomes