bbulla

FeatureSnapAgent problems

Discussion created by bbulla on Sep 9, 2010
Latest reply on Sep 10, 2010 by jeffmatson
Hi,

I need to be able to snap my custom tool to a few different features in my map.  I am trying to get the tool to snap to my Watermains first, but no luck.  Here is my code I have so far.  I think this is supposed to be setting up the SnapAgents, but something isn't working.  I get no errors, but my cursor for the tool isn't snapping to anything.

ISnapEnvironment snapEnvironment = m_editor as ISnapEnvironment;
snapEnvironment.ClearSnapAgents();

IFeatureSnapAgent featureSnapAgent = new FeatureSnapClass();
while (pLayer != null)
{
      switch (pLayer.Name)
      {
           case "GISADMIN.WaterMain":
           IFeatureLayer featureLayer = (IFeatureLayer)pLayer;
           IFeatureClass featureClass = featureLayer.FeatureClass;
                            
           featureSnapAgent.FeatureClass = featureClass;
           featureSnapAgent.HitType = esriGeometryHitPartType.esriGeometryPartBoundary;
           snapEnvironment.AddSnapAgent(featureSnapAgent);

            break;
       }

       pLayer = (ILayer2)allLayers.Next();
}

Outcomes