View Full Version : Reset DBMOD to avoid save prompt.
tplarkin7
14th Sep 2005, 06:15 pm
I would like to run a script (AutoCAD 2000i) at the opening of a drawing. When I do this, I am unable to close the drawing without getting the "do you want to save" dialogue box.
For example, when AutoCAD first launches, it makes a default drawing. If the script runs, AutoCAD assumes that changes have been made. So the default drawing stays open when I open a second file. I then have to close out of the default drawing and click "no".
Is there a command I can add to the end of the script that will "reset" the drawing to think that no changes have been made?
Thanks.
Spageddie
14th Sep 2005, 08:53 pm
:glare: Not that I'm aware, autocad will always ask to save the dwg on closing even if you have done NOTHING
rkmcswain
15th Sep 2005, 01:30 am
I would like to run a script (AutoCAD 2000i) at the opening of a drawing. When I do this, I am unable to close the drawing without getting the "do you want to save" dialogue box.
For example, when AutoCAD first launches, it makes a default drawing. If the script runs, AutoCAD assumes that changes have been made. So the default drawing stays open when I open a second file. I then have to close out of the default drawing and click "no".
Is there a command I can add to the end of the script that will "reset" the drawing to think that no changes have been made?
Thanks.
If DBMOD <> 0 then AutoCAD will always prompt you to save. Period.
The only way to do what you want is to set DBMOD back to 0.
There are two ways to do this.
1. Save the drawing
2. Use (acad-push-dbmod) and (acad-pop-dbmod) to save and restore the value of DBMOD. Before any changes are made to the drawing (when DBMOD=0), run (acad-push-dbmod), then after your script is finished, run (acad-pop-dbmod) to reset DBMOD back to 0
tplarkin7
15th Sep 2005, 08:56 pm
:glare: Not that I'm aware, autocad will always ask to save the dwg on closing even if you have done NOTHING
No.
If you open a drawing and do nothing, you can close it without saving and no dialogue will prompt you. You may have a script running that makes autocad think that you have made changes, so you will always get the save dialogue prompt. A script is a set of autocad commands in a text file. If this runs when opening a drawing, it is as if you typed those commands yourself, thus you get a save prompt when you close it.
tplarkin7
15th Sep 2005, 09:14 pm
If DBMOD <> 0 then AutoCAD will always prompt you to save. Period.
The only way to do what you want is to set DBMOD back to 0.
There are two ways to do this.
1. Save the drawing
2. Use (acad-push-dbmod) and (acad-pop-dbmod) to save and restore the value of DBMOD. Before any changes are made to the drawing (when DBMOD=0), run (acad-push-dbmod), then after your script is finished, run (acad-pop-dbmod) to reset DBMOD back to 0
Thanks rkmcswain,
The script I would like to run is only 2 simple commands which I just realized that I could likely include in the startup lisp file (probably). I will be back if I have problems. I did find more information regarding DBMOD for anyone that may need it.
From Google Groups:
Xolo,
you might look into this...maybe it can help
quote from acad2002 readme.hlp:
New functions provided to prevent a document from being marked "Updated"
Two new functions, acad-push-dbmod and acad-pop-dbmod, can be used to
suspend and resume the $DBMOD recording mechanism that AutoCAD uses to track
changes to a drawing. These functions allow applications to make changes to
a document as part of their initialization process without setting flags in
$DBMOD and triggering unwanted save drawing queries.
(acad-push-dbmod) pushes the current value of the $DBMOD system variable for
the document onto an internal stack. The function always returns T.
(acad-pop-dbmod) restores the value of $DBMOD to the most recently pushed
value on the document's internal stack. The function returns T for a
successful stack pop and nil if the stack is empty.
The acad-push-dbmod and acad-pop-dbmod functions are implemented in
acadapp.arx, which is loaded by default on AutoCAD startup, but can be
disabled, if desired.
To use the new functions, precede program actions that should not affect the
value of $DBMOD with calls to push the $DBMOD value, then pop the value
after performing the action. Here is a simple LISP example:
(acad-push-dbmod)
(setq new_line '((0 . "LINE") (100 . "AcDbEntity") (8 . "0")
(100 . "AcDbLine") (10 1.0 2.0 0.0) (11 2.0 1.0 0.0)
(210 0.0 0.0 1.0)))
(entmake new_line) ; Sets $DBMOD 1 flag
(command "_color" "2") ; Sets $DBMOD 4 flag
(command "_-vports" "_SI") ; Sets $DBMOD 8 flag
(command "_vpoint" "0,0,1") ; Sets $DBMMOD 16 flag
(acad-pop-dbmod) ; $DBMOD will again have the same value it had before
; the call to acad-push-dbmod
end quote
hth
Mark
tplarkin7
15th Sep 2005, 09:25 pm
I tried using the setvar command in acad.lsp and I get the save prompt.
So I will attempt to capture/restore the DBMOD in the acad.lsp. :cry:
tplarkin7
15th Sep 2005, 09:32 pm
Success!!! :D
No more save prompts when closing unchanged drawings!
I just entered the following code in the acad.lsp file (AutoCAD 2000i).
(acad-push-dbmod)
(SETVAR "LTSCALE" 0.375)
(SETVAR "PSLTSCALE" 1)
(acad-pop-dbmod)
Thanks rkmcswain!
Spageddie
15th Sep 2005, 10:35 pm
I know what scripts are :roll: , i'm basing my answer on the fact that if you have anything loading (Eg LISP, VBA macros ect.) then as far as autocad is concerned you have modified the drawing database and triggers the save prompt on closing.
At least that's how I see it... :unsure:
:glare: Not that I'm aware, autocad will always ask to save the dwg on closing even if you have done NOTHING
No.
If you open a drawing and do nothing, you can close it without saving and no dialogue will prompt you. You may have a script running that makes autocad think that you have made changes, so you will always get the save dialogue prompt. A script is a set of autocad commands in a text file. If this runs when opening a drawing, it is as if you typed those commands yourself, thus you get a save prompt when you close it.
Powered by vBulletin™ Version 4.0.6 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.