plackowski Posted December 22, 2016 Posted December 22, 2016 (edited) I need to know the end points (p1 and p2) of a line chosen by the user. How can I let them only select a single line? I'm currently using the following: (if (setq ss (ssget '((0 . "LINE")))) (setq l1ent (entget (ssname ss 0))) (setq p1 (cdr (assoc 10 l1ent))) (setq p2 (cdr (assoc 11 l1ent))) This works, but it still allows the user to grab more objects than necessary. I'm thinking I need to use entsel, but what if they select a different object? Would I need to create a while loop to keep prompting them until they choose a line, or is this functionality built into entsel? Edited December 22, 2016 by plackowski Quote
Grrr Posted December 22, 2016 Posted December 22, 2016 (setq SS (ssget "_+.:E:S" (list (cons 0 "LINE")))) For more info read here. EDIT: you could also force for selection: (while (not (setq SS (ssget "_+.:E:S" (list (cons 0 "LINE"))))) SS) Quote
satishrajdev Posted December 23, 2016 Posted December 23, 2016 You can use the ENTSEL with following loop. I have written it in simple way to make you understand. (while (not flag) (setq a (car (entsel "\nSelect Line : "))) (cond ((null a) (alert "Nothing selected, Please try again.")) ((= (cdr (assoc 0 (entget a))) "LINE") (alert "Selected object is line, Quitting the loop now.") (setq flag t) ) (t (alert "Selected object is not line, Please try again.")) ) ) Quote
plackowski Posted December 23, 2016 Author Posted December 23, 2016 That's perfect, thanks satishrajdev! I tried Grrr's method, but the code just ends if you click on anything that isn't a line, and the prompt still says Select Objects (plural). Quote
satishrajdev Posted December 23, 2016 Posted December 23, 2016 That's perfect, thanks satishrajdev!. Enjoy... Cheers Quote
Recommended Posts
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.