Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Show Message prompt Yes/No before continue

32 REPLIES 32
SOLVED
Reply
Message 1 of 33
JCprog
4935 Views, 32 Replies

Show Message prompt Yes/No before continue

Hello Everyone!Smiley Happy

 

I need help on the code below to ask the user if yes or no. If yes continue with the script, if no cancel routine. 

(initget "Yes No")
(if (eq (getkword "\nThis wil load & run someroutine, Do you wish to continue? [Yes/No] <No>: ") "Yes")
  (setvar '?????)
)
(load "C:/folder1/someroutine.lsp")
(command "someroutine")

 Thanks in advance!Smiley Happy

32 REPLIES 32
Message 21 of 33
Gary_J_Orr
in reply to: Lee_Mac

OK Mr. Lee Mac, How do you get the color coding and scroll bars so that the function looks just like it will in Vlisp editor?

oh, wait, don't want to highjack or sidebar the thread... you can email me directly if you want (email in signature)
-Gary
Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 22 of 33
Lee_Mac
in reply to: Gary_J_Orr

Gary_J_Orr wrote:
OK Mr. Lee Mac, How do you get the color coding and scroll bars so that the function looks just like it will in Vlisp editor?

oh, wait, don't want to highjack or sidebar the thread... you can email me directly if you want (email in signature)
-Gary

 

Email sent  Smiley Wink

Message 23 of 33
michael.missler15
in reply to: Lee_Mac

Hello,

I found this thread while looking for a way to get my lisp functions to be completed in a particular order and this seems to do this in a way by pausing for my input and confirming to continue with the last part of the lisp. I am wondering if there is a way to have "Yes" as the default, rather than "No"?  I made this edit to the lisp:

 

From:

(if (= "Yes" (getkword "\nLoad & run someroutine? [Yes/No] <No>: "))

To:

(if (= "Yes" (getkword "\nLoad & run someroutine? [Yes/No] <Yes>: "))

Which did change the default answer, but then the program wouldn't work.

 

Alternatively, I don't really need to answer "No", so if there is just a method to "pause" the lisp in order to make sure that the last part of the LISP comes after the first part.

 

I attached the .lsp file in case you want to goof around with it.

 

Thanks!

Michael

Message 24 of 33
dlanorh
in reply to: michael.missler15

(initget "Yes No")
(if (= "Yes" (cond ( (getkword "\nLoad & run someroutine? [Yes/No] <Yes>: ")) ("Yes")))
(progn
;.....Rest of "Yes" code here
)
(progn
;"No" code here if required
)
);end_if

The (initget) sets the answer to either "Yes" or "No"

The condition (cond) statement allows the user to press "enter" or right click with the mouse (if set up that way); and the default will be returned

 

(initget "Choices Here")
(if (= "Yes" (cond ( (getkword "\nLoad & run someroutine? [Choices/Here] <default>: ")) ("default")))

You can also

 

(initget "Yes No Maybe")
(setq ans (cond ( (getkword "\nLoad & run someroutine? [Yes/No/Maybe] <Yes>: ")) ("Yes")))

(cond (  (= ans "Yes")
             ;Yes Code
          )
         (  (= ans "No")
            ;No Code
         )
         (t
            ;Maybe Code since ans is not Yes or No
         )
);end_cond

I am not one of the robots you're looking for

Message 25 of 33


@michael.missler15 wrote:

... Alternatively, I don't really need to answer "No", so if there is just a method to "pause" the lisp in order to make sure that the last part of the LISP comes after the first part. ....

 

In that case, you can use any input function without prior (initget).

(getkword "\nPress enter to continue... ")

 ...or a space bar.

Message 26 of 33
michael.missler15
in reply to: dlanorh

Thanks, dlanorh. This works great!

 

Message 27 of 33

Hi BeekeeCZ, I'm wondering what you intended for the rest of the code.

This is what I had:

 

(initget "Yes No")
(if (= "Yes" (cond ((getkword "\nLoad & run someroutine? [Yes/No] <Yes>: ")) ("Yes")))
    (if (or c:ZoomAllandMakeFirstLayoutCurrent (and c:ZoomAllandMakeFirstLayoutCurrent)
	    );or
        (c:ZoomAllandMakeFirstLayoutCurrent)
        (princ "\nc:ZoomAllandMakeFirstLayoutCurrent could not be defined.")

This is what I have now and it seems to work fine:

(getkword "\nPress Enter to Continue : ")
(c:ZoomAllandMakeFirstLayoutCurrent)

Thanks!

Michael

 

Message 28 of 33

So this prompt was a great solution to my issue:  part of the code, which does a "zoom" "all" on all layouts, seemed to be "cutting in line" in front of other parts of the code that clean up the interface, instead of waiting for the "CleanScreen" and removal of status bar and such to happen before zooming.

I guess this (getkword...) function did some order of operations work on it that I needed. I wonder if there is a way to do the same thing without a user input prompt? Maybe a way to automatically input an "ENTER" after this:

(getkword "\nPress enter to continue : ")

Anyway, it's fun to try and polish off this code and thank you both!

 

Thanks,

Michael

Message 29 of 33


@michael.missler15 wrote:

.... Maybe a way to automatically input an "ENTER" after this:

(getkword "\nPress enter to continue : ")

...


 

🙂 kinda desperate. But you may try the DELAY command...

Message 30 of 33


@michael.missler15 wrote:

....Alternatively, I don't really need to answer "No", so if there is just a method to "pause" the lisp in order to make sure that the last part of the LISP comes after the first part. ....


 

How about an Alert?

 

  (alert "Ready to continue with next part of routine.")

 

You can carry on by either picking in the OK box in the Alert window or  pressing Enter or  space or  Esc.

Kent Cooper, AIA
Message 31 of 33

I tried (command "delay" "1000"), but it just paused for a moment before improperly zooming. The prompt for input worked fine, just an extra click! Hah, I'm always looking for less clicks and mouse movement!

 

Thanks,

Michael

Message 32 of 33

Wow, so it looks like "CleanScreen" was screwing with things all along. I removed it to try it out, inspired by your distaste for it, and here is what I came up with (I also added the hiding/showing of toolbars and filetabs, since cleanscreen was taking care of those:

;;;Custom Fullscreen ON
     (defun c:fw nil (c:FullScreenMode))
(defun c:FullScreenMode ()

  (command "commandlinehide")
  (setvar 'layouttab 0)
  (setvar 'menubar 0)
  (setvar 'statusbar 0)
  (command "filetabclose")
  (command "-toolbar" "michael" "hide")
  (c:ZoomAllandMakeFirstLayoutCurrent)
    
  (princ)
  );defun

;;;Custom Fullscreen Off
  (defun c:wf nil (c:FullScreenModeOff))
(defun c:FullScreenModeOff ()
  
  (command "commandline")
  (command "filetab")
  (setvar 'layouttab 1)
  (setvar 'menubar 1)
  (setvar 'statusbar 1)
  (command "filetab")
  (command "-toolbar" "michael" "show")
  (c:ZoomAllandMakeFirstLayoutCurrent)

  (princ)
 ); end defun

(vl-load-com)

; pbejse https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/layout-order/td-p/3749964
(defun :LayoutsRealOrder (/ order)
  (vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq order (cons (list (vla-get-name lay)
                            (vla-get-taborder lay))
                      order)))
  (mapcar 'car (cdr (vl-sort order '(lambda (j k) (< (cadr j) (cadr k)))))))

Thanks for the help!

 

-Michael

Message 33 of 33
jotaferrer
in reply to: Lee_Mac

Thank you! That's exactly what I wanted to!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost