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.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
@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.
@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.
Excellent! That's exact;y what I needed - I'll be able to put my little routine together now.
Thanks Kent, very helpful.
--
Gordon