Jump to content

How to retrieve the closest point to anything ...


MarcoW

Recommended Posts

Hi to all,

 

I read some interesting stuff about the vlax-curve-getClosestPointTo and I might find it useful for inserting blocks on lines etc. In my case I put 90% of the blocks (electrical symbols) on walls that are made of lines / plines / whatever an architect comes up with ..waiting.gif . (Note: these architect drawings are loaded as an xref under the actual drawing).

 

Now I allways use (via macro's):

 
*^C^C-insert;w1;s;$m=$(getvar,userr1)

Where w1 is the block name and the rest is used to get the correct scale size of the symbol. Because my osnaps automatically turns to "nearest" I manage to place them right on the line.

 

But I remember I once had an application that allowed me to left-click somewhere in front of the line and it would then insert the block on the nearest point.

 

thinking.gif How would that be done? For vlax-curve-getClosestPointTo seems only to work on curves, so not plines etc.

 

This is one of the useful places where I got my info so far:

http://www.asmitools.com/Files/AutoLISP_Help/Functions/vlax-curve-getClosestPointTo.html

Link to comment
Share on other sites

At the 'Specify insertion point' type nea (or select the "Nearest" icon from the Object snap toolbar... or Shift+right click to bring up the shortcut menu).

BTW... vlax-curve-getClosestPointTo works on plines, lines, circles, arcs... as long as they are VLA-objects

Link to comment
Share on other sites

At the 'Specify insertion point' type nea (or select the "Nearest" icon from the Object snap toolbar... or Shift+right click to bring up the shortcut menu).

BTW... vlax-curve-getClosestPointTo works on plines, lines, circles, arcs... as long as they are VLA-objects

 

I know it says that in the AutoLisp help, but they don't have to be VLA-OBJECTS. This works just fine:

(setq ent (entsel))
(setq pnt (vlax-curve-getclosestpointto (car ent) (cadr ent)))

I thought that too for a long time, until I forgot to convert and noticed it still worked.

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...