lastknownuser Posted August 16, 2022 Posted August 16, 2022 Need help with following, I want to write lisp to save drawing. I have the following: (setq dxfname (strcat (vl-filename-base (getvar "dwgname")))) (command "SAVEAS" "DXF" "VERSION" "2000" "" (strcat (getvar "dwgprefix") dxfname)) And when there already is a drawing with the same name, I get this message: "A drawing with this name already exists." and in that case I'd like to have DCL pop up and ask me if I want to replace it or not. My problem is how to save that command line text to create if function, something like (if (= message "A drawing with this name already exists.") ... ) Or if there is any other way to do what I want, please write your solutions, thanks! Quote
Steven P Posted August 16, 2022 Posted August 16, 2022 This is quite a simple one to use@ http://www.lee-mac.com/popup.html put in something like (setq Answer (LM:popup "Title Text" "This is a test message." 4) ) (if (= Answer 6) (progn (princ "Yes") ) ;end progn (progn (princ "No") ) ;end progn ) ;end if Quote
lastknownuser Posted August 16, 2022 Author Posted August 16, 2022 14 minutes ago, Steven P said: This is quite a simple one to use@ http://www.lee-mac.com/popup.html put in something like (setq Answer (LM:popup "Title Text" "This is a test message." 4) ) (if (= Answer 6) (progn (princ "Yes") ) ;end progn (progn (princ "No") ) ;end progn ) ;end if Thanks for this, but I created the DCL pop up, that is not the problem here. Problem is how to know if it needs to ask for replacement. for example here, if a drawing already exist (message "A drawing with this name already exists.") then (setq Answer (LM:popup "Save as dxf" "Overwrite existing dxf?" 1)). If not then just save as, no pop up needed. Hope I explained enough Quote
Steven P Posted August 16, 2022 Posted August 16, 2022 I was answering the worng thing then, how about this: ( (if dxfname (progn (princ "File Exists) ) ; End progn (progn (princ File Doesn't exist") ) ; End progn ) ; end if Quote
lastknownuser Posted August 17, 2022 Author Posted August 17, 2022 8 hours ago, Steven P said: I was answering the worng thing then, how about this: ( (if dxfname (progn (princ "File Exists) ) ; End progn (progn (princ File Doesn't exist") ) ; End progn ) ; end if No, even though drawing is not saved, dxfname variable exist (Drawing1, Drawing2,...) Quote
Steven P Posted August 17, 2022 Posted August 17, 2022 (edited) You could try (if (= (getvar 'DWGTITLED) 0) (princ "Drawing Not Saved") (princ "drawing Saved") ) to find out if the drawing has been saved Edited August 17, 2022 by Steven P 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.