Jump to content

How to stop Autolisp when user press Enter


Tharwat

Recommended Posts

Hi Everybody,

How can I stop running an Autolisp program when user intend to press .

For examlpe;

(defun c:ib (/ a count)
(setq a (cdr(assoc 2 (entget(car(entsel"\nSelect a Block: "))))))
(setq count 1)
(while count
(command "_insert" a pause "" "" "" ))
(princ "Written by Tharwat")
(princ))

Regards,

Tharwat

Link to comment
Share on other sites

Hi Everybody,

How can I stop running an Autolisp program when user intend to press

 

Maybe like this:

(while (setq ip (getpoint "\nInsert Point - (Enter To Exit):   "))
        (command "_insert" a ip "" "" "" ))

 

-David

Link to comment
Share on other sites

Maybe like this:

(while (setq ip (getpoint "\nInsert Point - (Enter To Exit):   "))
        (command "_insert" a ip "" "" "" ))

 

-David

 

Hi Mr.david

You said maybe and that was perfect, and what's if you were sure .:D

 

Thank you so much .

Tharwat

Link to comment
Share on other sites

Tharwat,

 

The drawback this is scenario is that you are not seeing the block insertion ( dragmode ) Not always necessary but it can be helpful in certain conditions. -David

Link to comment
Share on other sites

I use a check for nil in my loops make it your last line in the while

 

(setq x (getint "\n Enter number to exit)) ;1st time pick

 

(while (x nil) ;x is not nil CR pressed

 

etc

etc

 

(setq x (getint "\n Enter number to exit)) ; last line before endwhile

( ; endwhile

Link to comment
Share on other sites

  • 8 years later...

All I can say is "Thank You". I've been perusing the web intermittently for a couple of weeks looking for the answer and trying things which failed. I kept running into this one but without a clear understanding of how it worked (or enough understanding of how any of them worked really). It was only a reference in another forum that gave me a clue as to how to apply this answer to my immediate problem.

Link to comment
Share on other sites

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