Jump to content

Calculate least distance between two objects?


therock005

Recommended Posts

Suppose you have two seperate non-linear objects. At different points on the geometry of each object you get different distance between them. How can you find the least distance between them, i.e. the points on each of object in which the distance is the minimum of all possible distances?

 

EDIT: I am adding the picture example

 

2800fsw.jpg

 

So there's a crircle and a spline. And then there's three possible distances between them, from which the one marked red is the least from them. But the thing required here is the ABSOLUT minimum distance of all possible solutions for this problem, or any similar problem given two objects.

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • therock005

    5

  • alanjt

    5

  • MikeScott

    4

  • neodd70

    4

Top Posters In This Topic

Posted Images

Hmm... now this is tricky! Frankly, I'm not that good in Cartesian Geometry but as far as AutoCAD is concerned, I can suggest you a work-around.

 

Acad Geometrical.gif

 

Make a polyline starting from 1 and hit a perpendicular at 2, repeat this for 3, then 4 and go on until you find no apparent difference in the location of the newer points.

 

I know, a bit crude way, but that's the best that I can offer! :oops:

Link to comment
Share on other sites

Draw a line from Centerpoint of arc to centerpoint of arc, then trim it off at the arcs, and that line will represent the closest distance.

 

If there's no way to get two centerpoints, then Fahim's answer is as good as any I can come up with... Perhaps you could run a perpendicular line from the centerpoint of the circle, and it might nail it for you.. never tried that because I always have the two centerpoints.

 

*update* I tried it, and it worked like a charm, so if there's only one centerpoint availible, you do a line from that CENterpoint to PERpendicular to the other object. Thanks Fahim!

Link to comment
Share on other sites

...Try this, compliments from guys at theSwamp...
Reports the following error:

 

Command: md
Error: Automation Error. No database; error: An error has occurred inside the 
*error* functionAutoCAD variable setting rejected: "lunits" nil

:oops:

Link to comment
Share on other sites

ooh the error had an error within another error, but that's ok because it managed to replicate itself all over your harddrive first. :wink:

Link to comment
Share on other sites

ooh the error had an error within another error, but that's ok because it managed to replicate itself all over your harddrive first. :wink:

An attempt at humor or what?

I get no error here.

Link to comment
Share on other sites

I was joking about the error message that Fahim posted above mine.

 

The error that seemed, (to my non-code savy self) to come from within the error handler while it was handling another error.

 

We recently had a discussion about LSP viral programming, so I made a joke about it. I meant no offense by it. I don't try LSP scripts because I'm on 2004, and most newer ones won't work for me anyways. (plus my solution for this is quick enough for me anyways, though it might not work on some shapes).

 

Maybe it uses something in Civil 3d that's not in the standard 2008 release? The other person (non-civil 3d) got the error, while two Civil 3d 2008 folks apparently didn't get the error. Could be a million other things I guess, but without more info, that's the first thing I see as far as troubleshooting the error.

Link to comment
Share on other sites

Thank you guys for your usefull responses. I tried the lisp that was upped here. So let me guess how it works. Ir calculates all possible perpendicular distances between the two objects and then compares them to find the least one?

 

I would also like to tryyours too alanjt. What do you mean on your post that your routine needs the AT subroutine? What is this subroutine good for?

Link to comment
Share on other sites

I would also like to tryyours too alanjt. What do you mean on your post that your routine needs the AT subroutine? What is this subroutine good for?

 

It's a selection subroutine. Follow the link provided, save the subroutine in the same file as the Intersection file and load. However, the other posting is a lot nicer. Mine was just a proof-of-concept that I did a while back. I was just posting it as another example.

 

As you can see in the video, they do basically the same thing. :)

Link to comment
Share on other sites

It's a selection subroutine. Follow the link provided, save the subroutine in the same file as the Intersection file and load. However, the other posting is a lot nicer. Mine was just a proof-of-concept that I did a while back. I was just posting it as another example.

 

As you can see in the video, they do basically the same thing. :)

 

Well it'd be nice to give yours a try too. It looks neat as well, it even creates the intersecion points and a report window. :wink:

 

But you mean to save the subroutine in the same folder or destination? If i save it on the same file as the lisp it will overwrite the lisp leaving me with no main routine to execute! 8)

Link to comment
Share on other sites

...Try this, compliments from guys at theSwamp...

 

I stand to correct my earlier observation, this Lisp does work. However, I first ran in on Windows 2000, where it crashed. But on XP, the story is different :geek:

Link to comment
Share on other sites

Well it'd be nice to give yours a try too. It looks neat as well, it even creates the intersecion points and a report window. :wink:

 

But you mean to save the subroutine in the same folder or destination? If i save it on the same file as the lisp it will overwrite the lisp leaving me with no main routine to execute! 8)

Either way will work, but what I said is correct. Copy the subroutine and paste the contents in the intersection file (appending to existing data, not overwriting). LISP files can be viewed like text files, just scroll to the bottom and paste the contents of the sub.

Link to comment
Share on other sites

I Will try it on Monday as i'm away from my office pc right now! Will keep you posted with my feedback though. :)

Link to comment
Share on other sites

  • 7 years later...

I realize this is an old post but the minDist lisp function mentioned in here is very close to what I need and I was wondering if it could be altered for what I need or if there is maybe something else that would work better. I'm new to writing code so I can fumble thru simple routines but the complicated ones still stump me. What I am looking for is a lisp routine that would let me window select multiple entities (polylines, circles, arcs, splines) could be as few as 2 but as many as 30 or 40 and they could be closed or open, and have it determine and tell me if any of the entities are closer than a specified distance and if so maybe draw a line in red at the point or points that the entities are too close. Any help would be greatly appreciated. TIA

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...