Author Topic: How to detect a line near a Point? And then get the distance between them?  (Read 11764 times)

0 Members and 1 Guest are viewing this topic.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: How to detect a line near a Point? And then get the distance between them?
« Reply #15 on: December 21, 2016, 07:06:56 AM »
Hi,

keep in mind GetObjects<T> already filters by Entity type (T).

Code - C#: [Select]
  1. var closest = btr
  2.     .GetObjects<Line>(OpenMode.ForRead, false, true)
  3.     .Select(line => new { Line = line, Dist = pt.DistanceTo(line.GetClosestPointTo(pt, false)) })
  4.     .Aggregate((l1, l2) => l1.Dist < l2.Dist ? l1 : l2);
« Last Edit: December 21, 2016, 07:12:12 AM by gile »
Speaking English as a French Frog