• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    New Member
    Posts: 1
    Registered: ‎03-14-2012

    Curve.GetDistanceAt(Point3d) eInvalidInput exception

    106 Views, 1 Replies
    03-14-2012 07:01 AM

    Hi,

    I'm trying to get the distance of a PLINE pickpoint from the start of the PLINE. I'm trying to us the Curve.GetDistanceAt(Point3d) method to accompliche the job (see code below). The code throws an eInvalidInput exception. Why?

     

    Any thoughts?

     

    The Poit3d argument is the pickpoint of the PLINE.

     

    private double CurvePickPointDistance(ObjectId objectId, Point3d point3d)

    {

      double distance = 0;

      using (Transaction transaction = Acad.Transaction)

      {

       try

       {

        using (Curve polyLine = (Curve) transaction.GetObject(objectId, OpenMode.ForRead))

        {

         distance = polyLine.GetDistAtPoint(point3d);

        }

       }

       catch (Exception e) {}

      }

     return distance;

    }

    Please use plain text.
    Distinguished Contributor
    Posts: 372
    Registered: ‎06-27-2005

    Re: Curve.GetDistanceAt(Point3d) eInvalidInput exception

    03-14-2012 07:49 AM in reply to: Mikaza

    I don't think the pickpoint is necessarily on the actual polyline itself.  You can find the closest point using the polyline's method GetClosestPointTo(pickedpoint, True)

     

    -Mark

    Please use plain text.