Jump to content

Recommended Posts

Posted (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 by plackowski
Posted

(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)

Posted

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."))
 )
)

Posted

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

Posted
That's perfect, thanks satishrajdev!.

 

Enjoy... Cheers :beer:

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...