Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
Gordon_S
Posts: 83
Registered: ‎11-27-2008
Message 1 of 4 (368 Views)
Accepted Solution

Select line and get endpoint?

368 Views, 3 Replies
02-12-2013 12:42 PM

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.

*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 2 of 4 (359 Views)

Re: Select line and get endpoint?

02-12-2013 01:25 PM 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
*Expert Elite*
Kent1Cooper
Posts: 5,292
Registered: ‎09-13-2004
Message 3 of 4 (352 Views)

Re: Select line and get endpoint?

02-12-2013 02:28 PM 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
Valued Contributor
Gordon_S
Posts: 83
Registered: ‎11-27-2008
Message 4 of 4 (342 Views)

Re: Select line and get endpoint?

02-12-2013 03:32 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community