turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

Visual LISP, AutoLISP and General Customization

- Autodesk Community
- >
- AutoCAD Customization
- >
- Visual LISP, AutoLISP and General Customization
- >
- Closest points between two objects?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

853 Views, 5 Replies

04-29-2006 08:13 AM

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.

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-29-2006 10:15 AM in reply to:
*Fatfreek

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.

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"

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-29-2006 11:03 AM in reply to:
*Fatfreek

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.

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"

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"

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.

Distinguished Contributor

319 Posts

0 Kudos

Registered:
11-01-2004

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-29-2006 05:10 PM in reply to:
*Fatfreek

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-29-2006 07:06 PM in reply to:
*Fatfreek

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.

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.

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-10-2006 03:45 AM in reply to:
*Fatfreek

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

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

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Post to the Community

Have questions about Autodesk products? Ask the community.

The Knowledge Network

Access a broad range of knowledge to help get the most out of your products and services.

Download & Installation

Getting your Software

Downloads & Upgrades

Serial Numbers & Product Keys

Installation & Licensing

Activation & Registration

Network License Administration

Subscription Management

Sign In / Create Account

Maintenance Subscription Help

Desktop Subscription Help

Cloud Service Subscription FAQ

Announcements

Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.