Get CIMFeatureLayers in CIMGroupLayers

487
2
02-02-2022 11:13 PM
Kai_DA
by
New Contributor II

I am currently trying to access the FeatureLayers inside a GroupLayer via the CIM by accessing my Project-File, looping over the maps and then looking for the layers inside those maps.

Now I want to figure out which FeatureLayers belong to which GroupLayer. I am able to determine the GroupLayers of the map by checking if my current CIMObject is a CIMGroupLayer:

 

if (cimObject is ArcGIS.Core.CIM.CIMGrouplayer cimGroupLayer)
{
    var featureLayers = cimGroupLayers.Layers;
}

 

by accessing the "Layers" property of a GroupLayer I am getting the CIMPath as a string for each layer ("CIMPATH=some_layer_name.xml"). Is there any way of getting the 'clear name' for this layer by using this CIMPATH string you get from the Layers property?

There might also be another way around that which I haven't found out yet (it has to be done via accessing the CIM tho).

Many thanks in advance!

0 Kudos
2 Replies
BerndtNording
New Contributor III

Try t

      await QueuedTask.Run(() =>
      {
        ReadOnlyObservableCollection<Layer> lstLays;
        lstLays = MapView.Active.Map.Layers;
        foreach (Layer lay in lstLays)
        { 
          if (lay is GroupLayer)
          {
            GroupLayer pGrpLay = (GroupLayer)lay;
            ReadOnlyObservableCollection<Layer> featureLayers = pGrpLay.Layers;
            foreach (FeatureLayer fLay in featureLayers)
            {
              CIMBaseLayer fLayDef = fLay.GetDefinition();
              string pLayName = fLayDef.Name;
              MessageBox.Show(pLayName);
            }
          }
        }
      });

his:

0 Kudos
Kai_DA
by
New Contributor II

Many thanks for your reply!

I should've added that I am not able to use any Desktop-Extensions, since I am working on a standalone application and therefore I have to solely work with the Core assemblies.

0 Kudos