1

I want to know if the IPoint of the mouse position is hitting an IPolyline, I wrote this code, and was optimistic that it would work, but it always returns false.

  IPolyline poly1 = pc1 as IPolyline;

        IHitTest test = poly1 as IHitTest;
        if (test != null)
        {
            int a = 0;
            int b = 0;
            bool c = false;
            double distance = 0;
            IPoint hitPoint = new PointClass();
            bool isHit = test.HitTest(mousepoint,
                                    50000,
                                    esriGeometryHitPartType.esriGeometryPartNone,
                                    hitPoint,
                                    ref distance,
                                    ref a, ref b, ref c);


        }
2

I think you should probably not use esriGeometryHitPartType.esriGeometryPartNone, but choose a geometry part which you want to test.

In your case that would probably be esriGeometryHitPartType.esriGeometryPartBoundary, which means anywhere on the polyline.

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.