Author Topic: GetDistAtPoint  (Read 3761 times)

0 Members and 1 Guest are viewing this topic.

Bryco

  • Water Moccasin
  • Posts: 1882
GetDistAtPoint
« on: October 18, 2009, 11:15:53 AM »
I thought curve.GetDistAtPoint(curve.EndPoint) was the same as getting the length, but I just found out that a 3 point pline, where the startpoint=the endpoint has zero length. Help has the following
Quote
Calculates the length of the curve's segment between the curve's start point and point and returns the length.

If I draw a 3 point polyline where the endpoint is not quite the startpoint and the return leg has a different angle than the first leg the dist is the same as the length, so there is an inconsistancy there.

Checked on acad2010

sinc

  • Guest
Re: GetDistAtPoint
« Reply #1 on: October 18, 2009, 11:50:52 AM »
That doesn't surprise me.  When you specify the coordinate for the point, there is nothing to indicate whether you prefer the beginning or the end of the line.  So it returns the solution closest to the beginning of the line.

There are more quirks in here, too.  For example, using the option to find intersections on a polyline may return unexpected results at/near vertices if you use the option to extend the line.  And for Civil 3D users, these functions work differently on 3D-Polylines than on Feature Lines or Survey Figures (they use the 3D length on 3D Polylines, but the 2D length on the Civil 3D elements.)  There's a similar problem with GetParameterAtDistance.

In my experience, this whole area of Autocad is full of gremlins.  But at this point, there's an awful lot of other code all built on this stuff, so I don't really expect to see things change.  The only advice I can give is to do lots of testing of your code.  I've been able to work with all this stuff and can generally accomplish what I want, but there are a lot of quirks to discover.

Bryco

  • Water Moccasin
  • Posts: 1882
Re: GetDistAtPoint
« Reply #2 on: October 18, 2009, 12:41:02 PM »
Perhaps the worst part is that the use of the curve class is more limited for me. I could do some checks whether it was a line pline arc etc, but now without a lenght property I don't know what cuve is giving me.
Like you say sinc, lots of testing.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: GetDistAtPoint
« Reply #3 on: October 18, 2009, 07:32:03 PM »
 
Interesting, these give different answers in some conditions  :-o

Code: [Select]
...
editor.WriteMessage("\n{0} using param", curve.GetDistanceAtParameter(curve.EndParam));
editor.WriteMessage("\n{0} using point", curve.GetDistAtPoint(curve.EndPoint));
...


Bryco

  • Water Moccasin
  • Posts: 1882
Re: GetDistAtPoint
« Reply #4 on: October 19, 2009, 09:36:49 AM »
Ouch, I hope it doesn't get worse.