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

Select line and get endpoint?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Gordon_S
2543 Views, 3 Replies

Select line and get endpoint?

Can I select a line and get the nearest endpoint so I can do something to the line using the endpoint as a base?

 

Got an idea it will include an ssget and an osnap "end" in the code, but not too sure how to put it together.

3 REPLIES 3
Message 2 of 4
Kent1Cooper
in reply to: Gordon_S


@Gordon_S wrote:

Can I select a line and get the nearest endpoint so I can do something to the line using the endpoint as a base?

 

Got an idea it will include an ssget and an osnap "end" in the code, but not too sure how to put it together.


You could do it with (ssget), but for a single object, (entsel) is a little simpler.  In simplest terms, you can do this:

 

(setq

  linesel (entsel "\nSelect Line nearer desired endpoint: ")

  endpt (osnap (cadr linesel) "_end"); apply Osnap to selection point [second item in list returned by (entsel)]

)

 

You can get much fancier about it if you want, e.g.:

Test whether something was actually selected;

Test whether what was selected is, in fact, a Line;

If not either of the above, ask again rather than give up;

Set the APERTURE System Variable temporarily equal to the PICKBOX System Variable, which will avoid the possibility that something else within Osnap-aperture range of the pick point has an endpoint closer than the Line's.

Kent Cooper, AIA
Message 3 of 4
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

@Gordon_S wrote:

Can I select a line and get the nearest endpoint so I can do something to the line using the endpoint as a base?

....


....

(setq

  linesel (entsel "\nSelect Line nearer desired endpoint: ")

....


Then, the entity name of the Line would be (car linesel) [first item in list returned by (entsel)], which you could save into a variable for use in whatever you want to do with it, or just use it directly if you don't need it enough times for the variable to be a code savings.

Kent Cooper, AIA
Message 4 of 4
Gordon_S
in reply to: Kent1Cooper

Excellent! That's exact;y what I needed - I'll be able to put my little routine together now.

 

Thanks Kent, very helpful.

--

Gordon

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

Post to forums  

Autodesk Design & Make Report

”Boost