.NET

Reply
New Member
Mikaza
Posts: 1
Registered: ‎03-14-2012
Message 1 of 2 (161 Views)

Curve.GetDistanceAt(Point3d) eInvalidInput exception

161 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;

}

Mentor
MarkPendergraft
Posts: 375
Registered: ‎06-27-2005
Message 2 of 2 (156 Views)

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!