KRBeckman Posted March 2, 2010 Posted March 2, 2010 I'm in the progress of writing a lisp that will prompt the user to select an arc... The problem I'm having is that I can't figure out how to make sure the user is selecting an arc that is on layer "0" by looping until that criteria is met. Thanks in advance for your help. Quote
CALCAD Posted March 2, 2010 Posted March 2, 2010 KRBeckman, From your brief description, it seems that you might want to turn off all layers except "0" so the user can't pick from the wrong layer. Or am I not understanding the intent? Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 How about: (ssget "_:S" '((0 . "ARC") (8 . "0"))) Or more specifically in a loop: (while (not ss) (setq ss (ssget "_:S" '((0 . "ARC") (8 . "0"))))) Be sure to localise 'ss' though. Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 How about: (ssget "_:S" '((0 . "ARC") (8 . "0"))) Or more specifically in a loop: (while (not ss) (setq ss (ssget "_:S" '((0 . "ARC") (8 . "0"))))) Be sure to localise 'ss' though. Do you mind explaining how the while function works, more specifically why (while (not ss) makes it loop. Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Until a user makes a valid selection, the variable 'ss' is nil, and hence (not ss) return T, forcing the While to continue. To explain the WHILE as concisely as possible, the test expression is evaluated before each loop, and the statements following the test expression are only evaluated if the text expression returns a non-nil value. Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 ahhhh, when I was seeing (not ss) I was thinking it was checking if ss did not equal nil, which when the user is not selecting the correct type of object would be false. I get it now... (not ss) checks if ss is equal to nil. Little backwards from what I would think it be, but I get it. So then you could replace (not ss) with (= ss nil), right? Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 So then you could replace (not ss) with (= ss nil), right? Yes, but its not as elegant Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 Right, i just wanted to make sure I had it right. I'll have to start using that. Thanks again for the help. Quote
alanjt Posted March 2, 2010 Posted March 2, 2010 Yes, but its not as elegant Don't forget additional coding. Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Another couple of ways to approach it, if you prefer the behaviour of entsel: (while (progn (setq ent (car (entsel "\nSelect Arc: "))) (cond ( (eq 'ENAME (type ent)) (if (not (and (eq "ARC" (cdr (assoc 0 (entget ent)))) (eq "0" (cdr (assoc 8 (entget ent)))))) (princ "\n** Object is not an Arc on Layer \"0\" **"))) ( (princ "\n** Nothing Selected **"))))) (while (not ss) (setq ss (ssget "_+.:E:S" '((0 . "ARC") (8 . "0"))))) Lee Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 Here's a curveball... the arc i need to select is in modelspace, but needs to be selected in paperspace is this easily do-able? Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Certainly: (while (not ss) (setq ss (ssget "_+.:E:S" '((0 . "ARC") (8 . "0") (410 . "Model"))))) (Assuming you meant through a Viewport) Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 I like the first one... but I'll probably separate the alert into two depending on which criteria wasn't met. Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 I like the first one... but I'll probably separate the alert into two depending on which criteria wasn't met. I like that way of doing it too - just have to really keep an eye on your function returns to control the loop. Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 Certainly: (while (not ss) (setq ss (ssget "_+.:E:S" '((0 . "ARC") (8 . "0") (410 . "Model"))))) (Assuming you meant through a Viewport) Yeah, but I was hoping not to need the viewport to be active. Kinda like when using the "_dimangular" command. You can be in paperspace and select an arc in modelspace. Quote
alanjt Posted March 2, 2010 Posted March 2, 2010 I like the first one... but I'll probably separate the alert into two depending on which criteria wasn't met. Just out of curiosity, what would be the purpose of informing the user of something other than yes or no? Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 Just out of curiosity, what would be the purpose of informing the user of something other than yes or no? Because there is more than one criteria, it'd be nice to tell the user which criteria they missed. Quote
alanjt Posted March 2, 2010 Posted March 2, 2010 Because there is more than one criteria, it'd be nice to tell the user which criteria they missed. I understand that. I was just curious if you had some other reason to inform them. Quote
Lee Mac Posted March 2, 2010 Posted March 2, 2010 Yeah, but I was hoping not to need the viewport to be active. Kinda like when using the "_dimangular" command. You can be in paperspace and select an arc in modelspace. Pass :wink: Quote
KRBeckman Posted March 2, 2010 Author Posted March 2, 2010 Pass :wink: lol, understood, I didn't think it'd be easy. 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.