MarcoW Posted April 27, 2011 Share Posted April 27, 2011 Most of us have encountered the AutoCAD message: "Save changes to Drawing1.dwg?" Like this: In case of a new blank drawing in wich something is changed / added / etc. this is a logical thing. Sometimes this message appears even when nothing has changed in the drawing: opening a new AutoCAD session from scratch and then close it immediately without any input from the user results in the prompt wether so save it or not . Question is why does AutoCAD prompt for this when nothing has changed. Well the answer is easy: something did change but you did not notice. My situation: whenever AutoCAD opens a drawing, a new one or existing one, I have several Lisp routines that change setting so "the drawing behaves like I want it to". In other words: I changed some systemvariables. In the database of AutoCAD this is seen as a change and therefore it prompts to save it or not. In my case I have been pressing "no" for like a year or so. But now I found a way to protect myself against this prompt. If one is interested, please investigate the next two AutoCAD functions: acad-push-dbmod & acad-pop-dbmod. It is very simple to understand but I never had heard of it. I just happend to find it, lucky me. This is a small piece of code how I use it (based on some idea's from David Bethel): (defun SomeFunction (/ CmdEchoOld rst v var) (vl-load-com) ; load activeX functions (acad-push-dbmod) (setq CmdEchoOld (getvar 'CMDECHO)) (setq var '( ("CMDECHO" . 0) ("OSMODE" . 229) ("ORTHOMODE" . 1) ("GRIDMODE" . 0) ;; create your own list ) ) ;_setq (foreach v var (and (getvar (car v)) (setq rst (cons (cons (car v) (getvar (car v))) nw_rst)) (setvar (car v) (cdr v)) ) ;_and ) ;_foreach (setvar 'CMDECHO CmdEchoOld) (acad-pop-dbmod) (princ) ) ;_defun (SomeFunction) ; AutoLoad I thought maybe this can be of help to anyone else. Of course I am open to any additional info / suggestions / comments. Regards. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted April 27, 2011 Share Posted April 27, 2011 Three other options. 1. Get rid of all code that modifies the drawing at startup. 2. Set STARTUP to 1 to open AutoCAD with a startup dialog. 3. Set STARTUP to 2 (AutoCAD 2012 and later) to open AutoCAD with no drawing loaded. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 27, 2011 Share Posted April 27, 2011 (edited) ;;;--------------------------------------------------------------------; ;;; Load personal settings (defun c:LoadPersonalSettings (/ vars var val) (setq vars '(("cmdecho" . 0) ("osmode" . 229) ("orthomode" . 1) ("gridmode" . 0))) (foreach v vars (if (/= (setq val (cdr v)) (getvar (setq var (car v)))) (setvar var val))) (princ)) ;;;--------------------------------------------------------------------; ;;; Load personal settings - shortcut (defun c:LPS () (c:LoadPersonalSettings)) ;;;--------------------------------------------------------------------; ;;; Conditional load (if (= 1 (getvar 'dwgtitled)) [color=green]; If drawing is named (i.e., not Drawing1.dwg)[/color] (c:LPS)) [color=green]; Then load personal settings[/color] ;;;--------------------------------------------------------------------; (princ) [color=green]; Silent load[/color] Edited April 27, 2011 by BlackBox Quote Link to comment Share on other sites More sharing options...
MarcoW Posted April 27, 2011 Author Share Posted April 27, 2011 Thanks for the replies! @ rkmcswain: Your suggestions are no option to me: I want AutoCAD to set some variables the way I want. None of your suggestions will work the way I would like. Thanks anyway for sharing your idea! @ RenderMan Nice idea but this would mean that a new drawing is not set how I want them. So I need to save the file with a decent name and then close / reopen it. Thanks also! -> Still stick to my approach Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 27, 2011 Share Posted April 27, 2011 Thanks for the replies! @ rkmcswain: Your suggestions are no option to me: I want AutoCAD to set some variables the way I want. None of your suggestions will work the way I would like. Thanks anyway for sharing your idea! @ RenderMan Nice idea but this would mean that a new drawing is not set how I want them. So I need to save the file with a decent name and then close / reopen it. Thanks also! -> Still stick to my approach Your comments contradict the thread title. I'm not sure you understand the point... if you're not going to save Drawing1.dwg (i.e., avoid the "Save" prompt), then don't change the drawing at all. Could you not just change the desired System Variables in your Template (.DWT) to avoid -> your approach Quote Link to comment Share on other sites More sharing options...
designerstuart Posted April 27, 2011 Share Posted April 27, 2011 thanks marco for this topic, i have been interested in this ever since i started using a lisp to change a load of my variables now i am interested to see which method i will use........ let the discussion continue! Quote Link to comment Share on other sites More sharing options...
Dana W Posted April 27, 2011 Share Posted April 27, 2011 Well, in that case... Avoid touching the mouse wheel while drawing1.dwg is open. That causes about 99.9% of the cases where AutoCAD thinks you have changed drawing1.dwg. Even an unintentional zoom will set the change flag whether you move back to the original view or not. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted April 27, 2011 Author Share Posted April 27, 2011 Your comments contradict the thread title. I'm not sure you understand the point... if you're not going to save Drawing1.dwg (i.e., avoid the "Save" prompt), then don't change the drawing at all. Could you not just change the desired System Variables in your Template (.DWT) to avoid -> your approach What do you mean by "contradict"? I found why AutoCAD propmts for the and wanted to share my solution. It works and suits my situation. And since I do not contribute as much as others do to the forum I thought I'd share this. So let me return the question: do you understand the point? If I open an existing AutoCAD drawing by windows explorer then AutoCAD opens an empty drawing and the file I selected in the explorer. Without this code it remains and closes only after the prompt. With the code, the drawing1.dwg is closed automatically, I do not even notice it being opened. @ DesignerStuart: thanks for your reply. Let's see where this ends. In my case it works just fine! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 27, 2011 Share Posted April 27, 2011 Perhaps I've overlooked something; correct me where I may be wrong. What do you mean by "contradict"? The thread title is "How to prevent the 'Save Changes to Drawing1.dwg' message", and yet advocate changing system variables despite having no desire to save Drawing1.dwg ... this appears (to me) to be a contradiction. Why expend effort, only to discard the result? (^^ Sun Tzu would not approve ^^) If one wants to avoid the "Save Changes to Drawing1.dwg" prompt, the solution is simple... don't make changes prior to opening another, titled drawing. If you want to customize the System Variables (in a blank drawing), then the simplest solution is for those changes to be saved to your drawing template (DWT). However, not everyone has write-access to their DWT(s). Hence the code I posted... If a titled drawing is opened, one's personal settings are loaded automatically. However, if Drawing1 (a blank drawing) is opened, one's personal settings are not loaded... but it (SomeFunction) is still available to be manually called without the need to save the drawing, close, and re-open. I provide my users with a keyboard command for this (Example c:SomeFunction). I found why AutoCAD propmts for the and wanted to share my solution. It works and suits my situation. And since I do not contribute as much as others do to the forum I thought I'd share this. I've not made any attempt to deter you from posting things you feel will help others. Doing so is an admirable pursuit, and appreciated, as designerstuart has already pointed out. So let me return the question: do you understand the point? If I open an existing AutoCAD drawing by windows explorer then AutoCAD opens an empty drawing and the file I selected in the explorer. Without this code it remains and closes only after the prompt. With the code, the drawing1.dwg is closed automatically, I do not even notice it being opened. I do not experience this behavior... when I open a drawing from Windows Explorer only that drawing is opened, and not Drawing1. Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted April 27, 2011 Share Posted April 27, 2011 Guys...what difference does it make? If you don't want to do it that way, don't do it. I quite often open autocad to do some little something, sometimes just to see if it works, or to recreate a question that someone here has posted and don't save the drawing. Sometimes I do it because of some cryptic file name and the little preview bmp isn't big enough to tell what it is, so I open it to see if its what i'm looking for. If it's not, there is absolutely no reason to save it again. Now having said that, being the forgetful old windbag I am, I rely on that very dialog box to keep me from screwing up and either not saving something I should, or saving something I shouldn't. Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted April 27, 2011 Share Posted April 27, 2011 @ rkmcswain: Your suggestions are no option to me: I want AutoCAD to set some variables the way I want. None of your suggestions will work the way I would like. You are not understanding. For system variables that are not saved in the drawing, you can change them all day with your startup code. No problem. For system variables that ARE saved in the drawing, just set them in your template. Now when you open AutoCAD, "Drawing1.dwg" is opened, but as soon as you open the next drawing, "drawing1.dwg" goes away without it ever affecting you. :-) Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted April 27, 2011 Share Posted April 27, 2011 I rely on that very dialog box to keep me from screwing up and either not saving something I should' date=' or saving something I shouldn't. [/quote'] Which is the very reason I can't see introducing (acad-push-dbmod) and (acad-pop-dbmod) into any code. IMO - the only thing that should reset DBMOD to 0 is QSAVE, SAVEAS, and SAVE. Quote Link to comment Share on other sites More sharing options...
MarcoW Posted April 27, 2011 Author Share Posted April 27, 2011 Guys...what difference does it make? True. Thanks for your answer. You are not understanding.For system variables that are not saved in the drawing' date=' you can change them all day with your startup code. No problem. For system variables that ARE saved in the drawing, just set them in your template. Now when you open AutoCAD, "Drawing1.dwg" is opened, but as soon as you open the next drawing, "drawing1.dwg" goes away without it ever affecting you. :-)[/quote'] I do understand, that is not the issue. I know about drawing dependend variables etc. And I know that when you don´t want to save the drawing, then don´t change anything. I do not know everything but some things are obvious, come on guys. To be hounest: I feel this topic is going nowhere. I just wanted to share / show something I found to be very handy. Nothing more. I expected there would be things that could have been done better. Shure, thats the cool thing about forums. Too bad it turns out to become some kind of bickering. Maybe I shouldn't post this, but this is the way I see it. I mean no offence to anyone in particular let that be clear! Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 27, 2011 Share Posted April 27, 2011 You can only lead a horse to water... Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted April 28, 2011 Share Posted April 28, 2011 I do understand, that is not the issue. I know about drawing dependend variables etc. And I know that when you don´t want to save the drawing, then don´t change anything. @ rkmcswain: Your suggestions are no option to me: I want AutoCAD to set some variables the way I want. None of your suggestions will work the way I would like. Ok, those two statements above contradict one another. First you said that "none of your suggestions will work", but in fact #1 will work. If you do not change "drawing1.dwg" (with startup code or otherwise), then when you open another drawing, "drawing1.dwg" will go away on its own - no action needed. Then later you say that you understand about sysvars saved in the drawing. To be hounest: I feel this topic is going nowhere. I just wanted to share / show something I found to be very handy. Nothing more. I expected there would be things that could have been done better. Shure, thats the cool thing about forums. Too bad it turns out to become some kind of bickering. Maybe I shouldn't post this, but this is the way I see it. I'm not trying to bicker or be confrontational - I'm just looking out for future readers of this thread when it comes up on someone's google search a year from now... Your method may work for some users while it may not for others and I think pointing out the differences is good for everyone involved. I mean no offence to anyone in particular let that be clear! Same here. Thanks for posting. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 28, 2011 Share Posted April 28, 2011 I clarity. Quote Link to comment Share on other sites More sharing options...
designerstuart Posted April 28, 2011 Share Posted April 28, 2011 i think i like RenderMan's route the best - it seems pretty clean basically it applies your personal settings ONLY if the drawing is meaningfully changed, i.e. not called "drawing1.dwg" (correct me if i'm wrong) ;;;--------------------------------------------------------------------; ;;; Load personal settings (defun c:LoadPersonalSettings (/ vars var val) (setq vars '(("cmdecho" . 0) ("osmode" . 229) ("orthomode" . 1) ("gridmode" . 0))) (foreach v vars (if (/= (setq val (cdr v)) (getvar (setq var (car v)))) (setvar var val))) (princ)) ;;;--------------------------------------------------------------------; ;;; Load personal settings - shortcut (defun c:LPS () (c:LoadPersonalSettings)) ;;;--------------------------------------------------------------------; ;;; Conditional load (if (= 1 (getvar 'dwgtitled)) [color=green]; If drawing is named (i.e., not Drawing1.dwg)[/color] (c:LPS)) [color=green]; Then load personal settings[/color] ;;;--------------------------------------------------------------------; (princ) [color=green]; Silent load[/color] Thanks! ps. does this still work if it is Drawing2.dwg etc? - i don't understand the bit about (if (= 1 (getvar 'dwgtitled)) Quote Link to comment Share on other sites More sharing options...
Cad64 Posted April 28, 2011 Share Posted April 28, 2011 Now having said that' date=' being the forgetful old windbag I am, I rely on that very dialog box to keep me from screwing up and either not saving something I should, or saving something I shouldn't. [/quote'] Yup, what he said. Quote Link to comment Share on other sites More sharing options...
Lee Roy Posted April 28, 2011 Share Posted April 28, 2011 Nice codes and ideas. However, I'm +1 with Jack and Cad64...I tinker waaay too much. Sometimes I go back and forth between AutoCAD and Revit. Sometimes I save my tinkering, sometimes I don't, but I always rely on that dialog to let me know I've changed something that I probably forgot about while multitasking. To each his own. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted April 28, 2011 Share Posted April 28, 2011 i think i like RenderMan's route the best - it seems pretty cleanbasically it applies your personal settings ONLY if the drawing is meaningfully changed, i.e. not called "drawing1.dwg" (correct me if i'm wrong) ... ps. does this still work if it is Drawing2.dwg etc? - i don't understand the bit about (if (= 1 (getvar 'dwgtitled)) You're welcome; that is very kind of you to say. This 'setup' has worked the best for our environment, and users... that's not to say that will be the case for all others. Put simply, (= 0 (getvar 'dwgtitled)) given any DrawingN.dwg, and once a drawing has been saved with any non-DrawingN.dwg name (= 1 (getvar 'dwgtitled)). You are correct... Personal settings will only be *automatically* loaded if the drawing is named (i.e., not Drawing1.dwg, Drawing2.dwg, etc.). However the code I posted provides the ability for each user to manually load their personal settings at any time. Cheers! Quote Link to comment Share on other sites More sharing options...
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.