.NET

.NET

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

Curve.GetDistanceAt(Point3d) eInvalidInput exception

162 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: 385
Registered: ‎06-27-2005
Message 2 of 2 (157 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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.