Jump to content

Recommended Posts

Posted

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.

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • KRBeckman

    9

  • Lee Mac

    7

  • alanjt

    4

  • CALCAD

    1

Popular Days

Top Posters In This Topic

Posted

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?

Posted

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.

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

Posted

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.

Posted

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?

Posted
So then you could replace (not ss) with (= ss nil), right?

 

Yes, but its not as elegant :P

Posted

Right, i just wanted to make sure I had it right. I'll have to start using that. Thanks again for the help.

Posted
Yes, but its not as elegant :P

Don't forget additional coding.

Posted

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

Posted

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?

Posted

Certainly:

 

(while (not ss)
 (setq ss (ssget "_+.:E:S" '((0 . "ARC") (8 . "0") (410 . "Model")))))

 

(Assuming you meant through a Viewport)

Posted

I like the first one... but I'll probably separate the alert into two depending on which criteria wasn't met.

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

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

Posted
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?

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

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

Posted
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:

Posted
Pass :wink:

 

lol, understood, I didn't think it'd be easy.

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