Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to read all the link values from the Link Table(Present in the Spatial Adjustment Toolbar) in spatial Adjustment. I tried the below snippet from ESRI Website. It goes out of the loop after the first iteration although i have many links in my map. It executes without any errors.

public void GetLink()
{
  IMxDocument mxDoc = app.Document as IMxDocument;
  IGraphicsContainer graphicsContainer = mxDoc.FocusMap() as IGraphicsContainer;
  graphicsContainer.Reset();

  IElement element = graphicsContainer.Next();
  while (element != null)
  {
    if (element is IDisplacementLinkElement)
    { 
      IPolyline pLine = (IPolyline)element.Geometry;
      System.Windows.Forms.MessageBox.Show(pLine.FromPoint.X.ToString() + "," + pLine.FromPoint.Y.ToString());
    }
    element = graphicsContainer.Next();
  }
}

What would be the correct way of doing this?

share|improve this question
1  
For me, it seems to work okay. Make sure your links are really drawn in the default graphics layer of your focus map. Check the focus map's (active data frame's) "Annotation Groups" properties to see if there aren't any additional graphic layers to which the links could have been drawn. – Petr Krebs Jul 18 '12 at 10:06
@PetrKrebs - i checked "annotation groups"..there is only "default".. i tried on a new mxd too..links were added manually using the "new displacement link" tool – vinayan Jul 18 '12 at 10:17
@PetrKrebs - In which version did you get it working correctly? – vinayan Jul 19 '12 at 4:06
got the solution..it actually works..only thing is it doesn't work in the debug mode :-) – vinayan Jul 19 '12 at 5:06
I strongly doubt there is a difference when running in debug mode. Are you sure it is not a component registration issue? – Petr Krebs Jul 19 '12 at 7:41

closed as too localized by vinayan, whuber Jan 9 at 19:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.