Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Closest points between two objects?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
3472 Views, 5 Replies

Closest points between two objects?

The attached is a simple drawing of an angular line that is adjacent to an
enclosed polyline. I want to be able to code the nearest point on that poly
to the line.

It's easy to draw in Autocad. Osnap cen of the arc portion to perp of the
line gives a line. Then, the intersection of that line on the poly.

Tomorrow, the poly may not be that simple.

Len
--
To email reply, eradicate all threes in my SPAM guarded address.
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Hi Len,

Interesting question. Microstation has a command which returns the minimum distance
between any two selected objects. Obviously related to your question. I used MS in
the past, so I miss that command in AutoCAD.

I've done some research on this, Google searching the newsgroups. I found a comment
by Tony which said in effect, it simply can't be done in ACAD the way it's done in
MS. I don't recall the date of his comment. Things may have changed since then. Tony?

Anyway, assuming you want to pass these two objects to some function and find the
closest points without drawing. I think the only way is convert the arc in the pline
to a set of points. That trace function again. Pass each point to
(vlax-curve-getClosestPointTo curve-obj givenPnt) where curve-obj is the line. Then
determine which two pairs of points represent the minimum distance.

The downside is the result will not be the true mathematically correct answer. And
how much it strays depends on how many points the arc is broken into.

BTW, there's another way drawing. Perp snap to the line and perp snap to the arc in
the pline.

Joe Burke


"Fatfreek" wrote in message
news:5158898@discussion.autodesk.com...
The attached is a simple drawing of an angular line that is adjacent to an
enclosed polyline. I want to be able to code the nearest point on that poly
to the line.

It's easy to draw in Autocad. Osnap cen of the arc portion to perp of the
line gives a line. Then, the intersection of that line on the poly.

Tomorrow, the poly may not be that simple.

Len
--
To email reply, eradicate all threes in my SPAM guarded address.
Message 3 of 6
Anonymous
in reply to: Anonymous

Joe,

I think I spotted that thread, re Microstation and TonyT's comment about the
lack of Autodesk ability with that function.

Anyway, I note your suggestions with interest and will do my best to see if
I can't make one of them work.

Thanks very much.

Len

--
To email reply, eradicate all threes in my SPAM guarded address.
"Joe Burke" wrote in message
news:5158938@discussion.autodesk.com...
Hi Len,

Interesting question. Microstation has a command which returns the minimum
distance
between any two selected objects. Obviously related to your question. I used
MS in
the past, so I miss that command in AutoCAD.

I've done some research on this, Google searching the newsgroups. I found a
comment
by Tony which said in effect, it simply can't be done in ACAD the way it's
done in
MS. I don't recall the date of his comment. Things may have changed since
then. Tony?

Anyway, assuming you want to pass these two objects to some function and
find the
closest points without drawing. I think the only way is convert the arc in
the pline
to a set of points. That trace function again. Pass each point to
(vlax-curve-getClosestPointTo curve-obj givenPnt) where curve-obj is the
line. Then
determine which two pairs of points represent the minimum distance.

The downside is the result will not be the true mathematically correct
answer. And
how much it strays depends on how many points the arc is broken into.

BTW, there's another way drawing. Perp snap to the line and perp snap to the
arc in
the pline.

Joe Burke


"Fatfreek" wrote in message
news:5158898@discussion.autodesk.com...
The attached is a simple drawing of an angular line that is adjacent to an
enclosed polyline. I want to be able to code the nearest point on that poly
to the line.

It's easy to draw in Autocad. Osnap cen of the arc portion to perp of the
line gives a line. Then, the intersection of that line on the poly.

Tomorrow, the poly may not be that simple.

Len
--
To email reply, eradicate all threes in my SPAM guarded address.
Message 4 of 6
tader1
in reply to: Anonymous

Just a thought on your quest. Totally geometrical-there's prob. a better way, and this only realates to a curve & line or 2 curves i think. This is pretty redundant, but you could use deflection angle per foot and loop until your chord bearing is as close as parallel to your line, then calc the middle ordinate. The intersection of the middle ord. and the point on the curve should be the closest point? Just a thought. See attached.
Message 5 of 6
Anonymous
in reply to: Anonymous

Yes, looping is also an option. Extend a spaced series of perpendicular
lines from the line to the irregular object. The shortest one is closest,
then reverse direction and tighten the spacing -- and so forth till the
distance is at minimum -- within some fuzz factor.

This can be quite a chore if there are several protrusions from the object,
meaning there are several candidates on which is the closest.

Len
--
To email reply, eradicate all threes in my SPAM guarded address.
wrote in message news:5159033@discussion.autodesk.com...
Just a thought on your quest. Totally geometrical-there's prob. a better
way, and this only realates to a curve & line or 2 curves i think. This is
pretty redundant, but you could use deflection angle per foot and loop until
your chord bearing is as close as parallel to your line, then calc the
middle ordinate. The intersection of the middle ord. and the point on the
curve should be the closest point? Just a thought. See attached.
Message 6 of 6
Anonymous
in reply to: Anonymous

again with vlax-curve-getClosestPointToProjection ?
this is note a general solution, it's only a starting point. But I think
it's possible in a general.

[code]
; 1.060510
(setq eDxf (entget (car (entsel "\nSelect a line:"))))
(setq e10 (assoc 10 eDxf))
(setq e11 (assoc 11 eDxf))
(setq ax (nth 1 e10) ay (nth 2 e10) bx (nth 1 e11) by (nth 2 e11))
(setq vector (list (- bx ax) (- by ay) 0.0))
(setq normal (list (* 10000 (- ay by)) (* 10000 (- bx ax)) 0.0))
(vlax-curve-getClosestPointToProjection
(vlax-ename->vla-object (car (entsel "\nSelect polyline:")))
normal
vector
)
[/code]

return : (-0.35757 0.0438876 0.0) , it's the good point

Bruno Toniutti

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost