4

I'm trying to use a standalone snap agent. Is that not possible?

Here's some code:

        // instantiate these agents.
        _snapSupportAgent = new FeatureSnapClass();
        _snapSupportAgent.FeatureClass = _parcelSplitLine;
        _snapSupportAgent.HitType = esriGeometryHitPartType.esriGeometryPartBoundary;

        _snapParcelAgent = new FeatureSnapClass();
        _snapParcelAgent.FeatureClass = _parcelSplitLine;
        _snapParcelAgent.HitType = esriGeometryHitPartType.esriGeometryPartBoundary;

Later on code:

        var newPoint = new PointClass();
        _snapParcelAgent.Snap(null,newPoint,1);

When I do that, I get a nasty protected memory exception. I'm editing directly to a IWorkspaceEdit, without interference of the IEditor.

  • Did you try using IEngineSnapAgent instead? There's a sample here. – Kirk Kuykendall Dec 15 '12 at 17:20
  • I'll try that, but it's not an engine application. It's working under a custom form with a AxMapControl, true, but it's not ArcEngine... – George Silva Dec 17 '12 at 14:23
3

I can't find the documentation now, but AFAIK, Snapping can only be done using the ISnapEnvironment Interface via the IEditor.

The IFeatureSnap is used in two kinds of cases: Defining a custom snap agents or accessing the snap agents in the snap environment. It is the snap environment which actually does the snapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.