Slow IGxlayer access/broken links

383
3
06-26-2012 06:39 AM
CarlosPiccirillo
New Contributor III
Hi everyone,

I am trying to write some code that will check a layer file for broken links when the layer gets loaded in code. The code below works fine but the very first line (red line of code below) where it checks to see if the layer file has a group layer is very slow. It's taking 25 to 30 seconds consistently and I don't know why. The code below is part of a much larger program and since this script will be used every time a layer is loaded, I cannot have it taking 30 seconds for every layer because in certain cituations, 30 to 40 layers can get loaded one after another.

Thanks for your time to read this.
Carlos

internal static bool IsLayerFileValid(IGxLayer pGxLayer)
{
    ICompositeLayer pCompositeLayer = null;
    IGroupLayer pGroupLayer = new GroupLayerClass();
    ILayer pLayer = null;
    IEnumLayer pEnumLayer = null;

    try
    {
 if (!(pGxLayer.Layer is IGroupLayer)) 
        {
     if (pGxLayer.Layer.Valid == false)
     {
  return false;
     }
 }
 else
 {
     //pGroupLayer = pGxLayer.Layer as IGroupLayer;
     pCompositeLayer = pGxLayer.Layer as ICompositeLayer;

     for (int counter = 0; counter < pCompositeLayer.Count; counter++)
     {
  pLayer = pCompositeLayer.get_Layer(counter);

  if (pLayer.Valid == false)
  {
      return false;
  }
     }
 }

 return true;
    }
    catch (Exception ex)
    {
 MessageBox.Show(ex.Message);
 return false;
 //throw;
    }
}
0 Kudos
3 Replies
JamesCrandall
MVP Frequent Contributor
Carlos --- did you resolve this issue or make any progress?
0 Kudos
CarlosPiccirillo
New Contributor III
James,

I got pulled away from this project and have not gotten back to it because now my boss wants to do this in Python instead of C# and I'm not the Python programmer in our group.

Sorry I couldn't be of more help.

Carlos
0 Kudos
JamesCrandall
MVP Frequent Contributor
James,

I got pulled away from this project and have not gotten back to it because now my boss wants to do this in Python instead of C# and I'm not the Python programmer in our group.

Sorry I couldn't be of more help.

Carlos


Oh you will love all of that Python -- it' such a clean programming language to write (ha) 😄

No problem --- good luck!
0 Kudos