Author Topic: Get closest line to promtpointresult  (Read 1949 times)

0 Members and 1 Guest are viewing this topic.

JohanMagnusson

  • Guest
Get closest line to promtpointresult
« on: July 01, 2009, 01:59:07 PM »
Hi everyone, im new around here and hope that some of you might be able to give me a hint of how to solve my problem.

I want to get the closest line in a specific direction from a promtpointresult. The lines will be in a specific layer.

With this i want to be able to trace ie. the walls of a room if i click inside the room.

Im using Autocad 2010 and visual studio 2008.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Get closest line to promtpointresult
« Reply #1 on: July 01, 2009, 08:47:36 PM »
Welcome Johan. I would start by looking at selectionsets (the search here has some good examples).
You want to make a selectionset that filters for lines and your layer.
Then you can find out which is closest.

wannabe

  • Guest
Re: Get closest line to promtpointresult
« Reply #2 on: July 02, 2009, 03:10:41 AM »
I've got a routine that gets the me the nearest point on a curve (line/polyline) by using the Curve.getNearestPointTo(). The best I can suggest is to scan every curve and use this method to infer the shortest distance. However, this might not be optimal.

Please let us know how you get on.

Nick

JohanMagnusson

  • Guest
Re: Get closest line to promtpointresult
« Reply #3 on: July 02, 2009, 04:07:42 AM »
Thanks for your quick replies!

I will look into your suggestions and do some testing,  will post back on my results.

and thanks again for getting my motivation back ;)

hmspe

  • Bull Frog
  • Posts: 362
Re: Get closest line to promtpointresult
« Reply #4 on: July 02, 2009, 12:34:34 PM »
Just curious -- is there a reason you can't use the BOUNDARY command or the HATCH command? 

Just finding the closest line in a given direction does not necessarily guarantee that you'll trace a room's walls.  Consider a room shaped like an "L" or like a "U", or any room with recesses in the walls.  Its easy to have walls that can't be be seen from a selection point.

I don't program in .NET, but I have been pondering this problem for a while.  There are a number of ways to get an inside boundary.  A few links are:
http://www.theswamp.org/index.php?topic=10371.0
http://www.theswamp.org/index.php?topic=26986.0
http://www.theswamp.org/index.php?topic=24000.0

A few things to look out for are gaps (lines that appear to touch do not always do so due to sloppy drafting, conversions from other systems, or rounding errors) and very small changes in the surface (for example, a wall with a "picture frame" surface where the surface bumps out 1/2" -- it can be hard to pick up very small changes to the surfaces).  I'm toying with a lisp routine which will draw an arbitrary construction from a selected point to find a starting point on the boundary, then trace around the space.  I'm using the same approach as in fastsel.lsp (one of the express tools), which is to use getss with the fence option.  Fastsel gets selection sets on the base entity, a small offset to the right, and a small offset to the left.  Curves are done in segments.  My code looks at a fence offset toward the inside of the room.  If nothing is found it looks at a small crossing window at the far end of the base entity, which will find end-to-end line segments and intersections which turn away from the inside of the room.  If still nothing it looks at a fence offset to the outside to catch situations where the first line overshoots the intersection. 

"Science is the belief in the ignorance of experts." - Richard Feynman