Dj_T_Rex2002 Posted January 5, 2016 Posted January 5, 2016 I have a lisp routine that runs Zoom Extents, Purge, Audit and Save twice (below) ... my question is, when typing "PNA" command, is there a way to add a dialog box that pops up to either proceed or cancel the command? (DEFUN C:PNA () (C:TA) (COMMAND "ZOOM" "E") (COMMAND "-PURGE" "A" "" "N") (COMMAND "AUDIT" "Y") (COMMAND "QSAVE") (COMMAND "QSAVE") ) Quote
Lee Mac Posted January 5, 2016 Posted January 5, 2016 You could use my Popup function in the following way: (defun c:pna nil (cond ( (null c:ta) (princ "\nTA command not defined.") ) ( (null LM:popup) (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ) ( (= 6 (LM:popup "Proceed?" "Would you like to proceed with this command?" 36)) (c:ta) (command "_.zoom" "_e" "_.-purge" "_a" "" "_n" "_.audit" "_y" "_.qsave") ) ) (princ) ) Quote
Dj_T_Rex2002 Posted January 5, 2016 Author Posted January 5, 2016 Hi Lee Mac, thanks for the modification. It did not work on my machine and maybe reason being is that the TA command is a LISP a guy created here at work. So basically what I'm trying to do is run his LISP before it can do the rest. I just want to be able to add an OK and CANCEL button at the beginning before it executes anything. Quote
Lee Mac Posted January 5, 2016 Posted January 5, 2016 You're welcome. It did not work on my machine and maybe reason being is that the TA command is a LISP a guy created here at work. What happened exactly? Do you receive an error message? Quote
BIGAL Posted January 6, 2016 Posted January 6, 2016 (edited) Maybe this also (acet-ui-message message [caption [type]]) where type is 1 for OKCANCEL (if (= (acet-ui-message "this is test" "pick ok or Cancel" 1) 2)(exit)) Edited January 6, 2016 by BIGAL Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 Maybe this also (acet-ui-message message [caption [type]]) where type is 1 for OKCANCEL (if (= (acet-ui-message "this is test" "pick ok or Cancel" 1) 2)(exit)) That's what I needed BigAl ... (DEFUN C:PNA () (if (= (acet-ui-message "This will Purge, Audit and Double Save. Ok to proceed?" "pick ok or Cancel" 1) 2)(exit)) (C:TA) (COMMAND "ZOOM" "E") (COMMAND "-PURGE" "A" "" "N") (COMMAND "AUDIT" "Y") (COMMAND "QSAVE") (COMMAND "QSAVE") ) LeeMac thanks for your help too. The error it gave me was "TA command not defined" and "popup function not defined - download this function from http://lee-mac.com/popup.html" Quote
Lee Mac Posted January 6, 2016 Posted January 6, 2016 The error it gave me was "TA command not defined" Yes, the TA function would need to be loaded - this would have equally applied to your original code. ...and "popup function not defined - download this function from http://lee-mac.com/popup.html" Yes, you would need to download & load my Popup function from the link I provided in my above post before running the code. These are not error messages (no error has occurred) - they are message for your information. You can use the acet-* functions, but be mindful that these are Express Tools functions and will hence only be available if Express Tools are installed. Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 Lee Mac I tried using the code you provided but came back with ";error: no function definition: LM:POPUP". Even though it says MS_ACAD.lsp successfully loaded. (defun c:pna nil (cond ( (null c:ta) (princ "\nTA command not defined.") ) ( (null LM:popup) (LM:Popup "Title Text" "This is a test message." (+ 1 16 4096)) ) ( (= 6 (LM:popup "Proceed?" "Would you like to proceed with this command?" 36)) (c:ta) (command "_.zoom" "_e" "_.-purge" "_a" "" "_n" "_.audit" "_y" "_.qsave" "_.qsave") ) ) (princ) ) Quote
Lee Mac Posted January 6, 2016 Posted January 6, 2016 Lee Mac I tried using the code you provided but came back with ";error: no function definition: LM:POPUP". Even though it says MS_ACAD.lsp successfully loaded. ( (null LM:popup) (LM:Popup "Title Text" "This is a test message." (+ 1 16 4096)) ) You are not using the code I originally provided - you have modified my example and you are now trying to evaluate the function under the condition that it is not defined - this will obviously error and is the very reason why my original code above included this condition accompanied by a message to state that the function must be loaded. What is MS_ACAD.lsp? Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 MS_ACAD.lsp is the notepad file where I keep all of the lisps ... I tried putting the first one you provided: (defun c:pna nil (cond ( (null c:ta) (princ "\nTA command not defined.") ) ( (null LM:popup) (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ) ( (= 6 (LM:popup "Proceed?" "Would you like to proceed with this command?" 36)) (c:ta) (command "_.zoom" "_e" "_.-purge" "_a" "" "_n" "_.audit" "_y" "_.qsave") ) ) (princ) ) but I got this ... LM:popup function not defined - download this function from http://lee-mac.com/popup.html Yes, you would need to download & load my Popup function from the link I provided in my above post before running the code. So I went to your link (amazing link by the way and can't wait to learn from it) and saw the information in there so I thought maybe you meant I needed to change this line: ... (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ;this line ... Yes, the TA function would need to be loaded - this would have equally applied to your original code. Well I have no idea how to do this because I am just trying to call on a lisp that this other guy created and is an .fas file. The only way I know how to use it is if I leave it before I do any command like: (defun c:pna () (ta) (command ...) However I have no idea why there is a nil like you have it in the code. Quote
Lee Mac Posted January 6, 2016 Posted January 6, 2016 So I went to your link and saw the information in there so I thought maybe you meant I needed to change this line: ... (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ;this line ... There is no need to change any of the code: simply copy the code (including the code header) from the link I provided to your MS_ACAD.lsp or to a separate AutoLISP file and ensure that the code is loaded (and hence the function defined) before using the example program I provided. You can include the code for my LM:popup function alongside the above code if you wish, e.g.: (defun c:pna nil (cond ( (null c:ta) (princ "\nTA command not defined.") ) ( (null LM:popup) (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ) ( (= 6 (LM:popup "Proceed?" "Would you like to proceed with this command?" 36)) (c:ta) (command "_.zoom" "_e" "_.-purge" "_a" "" "_n" "_.audit" "_y" "_.qsave") ) ) (princ) ) ;;-------------------------=={ Popup }==----------------------;; ;; ;; ;; Displays a pop-up message box prompting the user. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; title - Text to be displayed in the pop-up title bar ;; ;; msg - Text content of the pop-up message box ;; ;; flags - Integer indicating icon & button appearance ;; ;; Reference: http://lee-mac.com/popup.html ;; ;;------------------------------------------------------------;; ;; Returns: Integer indicating the button pressed to exit ;; ;;------------------------------------------------------------;; (defun LM:popup ( title msg flags / wsh res ) (if (setq wsh (vlax-create-object "wscript.shell")) (progn (setq res (vl-catch-all-apply 'vlax-invoke-method (list wsh 'popup msg 0 title flags))) (vlax-release-object wsh) (if (null (vl-catch-all-error-p res)) res ) ) ) ) (amazing link by the way and can't wait to learn from it) Thanks - I'm glad you like my site Well I have no idea how to do this because I am just trying to call on a lisp that this other guy created and is an .fas file. That changes things - if your colleague compiled the program to a separate namespace FAS file then you will not be able to call the function from another program, as the function will not be exposed to the document namespace. Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 That changes things - if your colleague compiled the program to a separate namespace FAS file then you will not be able to call the function from another program, as the function will not be exposed to the document namespace. Well I was able to call it before by doing the original code (DEFUN C:PNA () (C:TA) ... We are able to load it in our AutoCAD from the Load/Unload Applications and it's in the Contents ... I just want to be able to call use that before all the other stuff. Isn't there a way to call it like I had it above? I wanted to modify the code you gave me by putting the c:TA before the rest of the code but I'm afraid I will screw it up somehow lol Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 I think it's actually working. It does call the TA command which is THAW ALL lol. Thanks Lee Mac Quote
Lee Mac Posted January 6, 2016 Posted January 6, 2016 I think it's actually working. It does call the TA command which is THAW ALL lol. Thanks Lee Mac If it's only a 'thaw-all' program, you might as well simply use: (defun c:pna nil (if LM:popup (if (= 6 (LM:popup "Proceed?" "Would you like to proceed with this command?" 36)) (command "_.-layer" "_t" "*" "" "_.zoom" "_e" "_.-purge" "_a" "" "_n" "_.audit" "_y" "_.qsave") ) (princ "\nLM:popup function not defined - download this function from http://lee-mac.com/popup.html") ) (princ) ) Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 So if the lisp is calling out to use it from an html source. What happens if your server goes down or wherever it is grabbing it from? Will it still work or will it just cause an error message? Quote
Lee Mac Posted January 6, 2016 Posted January 6, 2016 So if the lisp is calling out to use it from an html source. What happens if your server goes down or wherever it is grabbing it from? Will it still work or will it just cause an error message? The program is not automatically downloading the function from my site (though, that would be possible) or accessing the function from my site - in these examples, the code for the relevant supporting functions would need to be downloaded and included with the program. Quote
Dj_T_Rex2002 Posted January 6, 2016 Author Posted January 6, 2016 You're the best. Thanks for always being there to help Lee 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.