• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    Posts: 80
    Registered: ‎11-27-2008
    Accepted Solution

    Select line and get endpoint?

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

    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,159
    Registered: ‎09-13-2004

    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
    Please use plain text.
    *Expert Elite*
    Kent1Cooper
    Posts: 4,159
    Registered: ‎09-13-2004

    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
    Please use plain text.
    Valued Contributor
    Posts: 80
    Registered: ‎11-27-2008

    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

    Please use plain text.