#1 Tue 31 August 2004 18:31
- Eric BRENNER
- Invité
ArcObject - index <-> nom
bonjour a tous,
une question toute bete...
comme en arcobject recuperer l'index d'une couche si l'on a son nom et inversement ?
--
ERIC BRENNER
IFREMER - DEL/PAC TOULON
www.ifremer.fr
----------------------------------
#2 Tue 31 August 2004 18:31
- Olivier GUYOT-DE-LA-POMMERAYE
- Invité
Re: ArcObject - index <-> nom
Bonjour,
Pour recuperer l'index d'une couche a partir de son nom pas d'autres choix que de parcourir la collection de couches.
Voici une fonction pour Recuperer une FeatureLayer a partir de son nom, vous pouvez aisement la modifier pour ne recuperer que l'index.
Code:
Public Function GetFeatureLayerByName(LayerName As String) As IFeatureLayer
    Dim oDoc As IMxDocument
    Dim oMap As IMap
    Dim oLayer As ILayer
    Dim oEnumLayer As IEnumLayer
    Dim oId As New UID
    'Instanciation des Objets ArcMap
    Set oDoc = ThisDocument
    Set oMap = oDoc.FocusMap
    oId = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"
    Set oEnumLayer = oMap.Layers(oId, True)
    oEnumLayer.Reset
    Set oLayer = oEnumLayer.Next
    Do While Not oLayer Is Nothing
        If oLayer.Name = LayerName Then
            Set GetFeatureLayerByName = oLayer
            Exit Do
        End If
        Set oLayer = oEnumLayer.Next
    Loop
End FunctionSinon, pour connaitre le nom quand on a l'index c'est simple :
 --> oMap.Layer(oIndex).Name
Cordialement,
Olivier Guyot de La Pommeraye





