TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Matt__W on August 10, 2011, 11:49:19 AM

Title: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 11:49:19 AM
In my custom ACAD.lsp file I have (acad-push-dbmod) at the beginning and (acad-pop-dbmod) at the end, yet every time I check DBMOD after opening AutoCAD, it has a value of 5.

Thoughts?  Suggestions??
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 12:11:13 PM
Are you making edits to the drawing upon startup? Mine always says 5, but I also have it insert all styles (dim, mleader) and create/reset textstyles.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Krushert on August 10, 2011, 12:12:22 PM
Well you could just save the drawing file and that will reset it back to zero.  :-P :evil:
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 12:14:07 PM
Well you could just save the drawing file and that will reset it back to zero.  :-P :evil:
Sucky prompt to receive when starting a new drawing (granted, you could it to only save if not a "Drawing#.dwg" file).
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Krushert on August 10, 2011, 12:32:30 PM
Well you could just save the drawing file and that will reset it back to zero.  :-P :evil:
Sucky prompt to receive when starting a new drawing (granted, you could it to only save if not a "Drawing#.dwg" file).

**We really need to get a sarcasm smilely.**  :-)
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 12:35:36 PM
Well you could just save the drawing file and that will reset it back to zero.  :-P :evil:
Sucky prompt to receive when starting a new drawing (granted, you could it to only save if not a "Drawing#.dwg" file).

**We really need to get a sarcasm smilely.**  :-)
(http://www.theswamp.org/index.php?action=dlattach;attach=3264;type=avatar)
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Krushert on August 10, 2011, 12:47:13 PM
 :-D :-D :-D
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: dgorsman on August 10, 2011, 01:13:00 PM
Possibly from using ACAD.lsp rather than ACADDOC.lsp?  Or there may be drawing changes made in an appended S::STARTUP function which runs after the push/pop dbmod setting?  Or drawing changes made by an MNL depending on the load order of the MNL vs. the ACAD.lsp.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 01:26:40 PM
Well you could just save the drawing file and that will reset it back to zero.  :-P :evil:
Sucky prompt to receive when starting a new drawing (granted, you could it to only save if not a "Drawing#.dwg" file).

**We really need to get a sarcasm smilely.**  :-)
(http://www.theswamp.org/index.php?action=dlattach;attach=3264;type=avatar)
OOOHHH, BURN!!!
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 01:27:20 PM
Possibly from using ACAD.lsp rather than ACADDOC.lsp?  Or there may be drawing changes made in an appended S::STARTUP function which runs after the push/pop dbmod setting?  Or drawing changes made by an MNL depending on the load order of the MNL vs. the ACAD.lsp.
Oooh, MNL.  Forgot about that one.  I'll go check.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: BlackBox on August 10, 2011, 01:40:28 PM
In my custom ACAD.lsp file I have (acad-push-dbmod) at the beginning and (acad-pop-dbmod) at the end, yet every time I check DBMOD after opening AutoCAD, it has a value of 5.

Thoughts?  Suggestions??

Edit: Scratch... just saw dgorsman's quoted post from previous page.

I also use ACAD.lsp to set profile paths, etc., however DBMOD = 0 at start with Drawing1.

Consider the load order at startup:
linky (http://www.blog.cadnauseam.com/2008/09/01/what-is-loaded-at-autocad-startup-and-when/)

Quote
A. CUI files loaded:
1. Enterprise
2. Main
3. Partials to Main
4. Partials to Enterprise

B. acad*.* files loaded:
1. Files listed in acad.rx
2. acad2009.lsp
3. acad.lsp  <--  
4. acad2009doc.lsp
5. acaddoc.lsp
6. acad.dvb

C. CUI-associated MNL and LSP files loaded:
1. Enterprise named MNL
2. Enterprise loaded LSP and MNL
3. Main named MNL
4. Main loaded LSP and MNL
5. Partials to Main named MNLs
6. Partials to Main loaded LSPs and MNLs
7. Partials to Enterprise named MNLs
8. Partials to Enterprise loaded LSPs and MNLs

D. Startup suite files loaded

E. Startup routines run:
1. AcadStartup() called (AutoCAD startup)
2. AcadDocument_Activate() called (Drawing startup)
3. (S::STARTUP) called
4. SCR loaded from /b switch

Edit: ^^ Corrected

... Is it possible that you have something loading/executing via ACADDOC.lsp, CUI(s), or (S::STARTUP)?
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 01:49:24 PM
I'm running/loading a few things in S::Startup but that's between the PUSH/POP.  Hehehehe... pushpop!  I didn't think that would make a difference.  Maybe it does??
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 01:51:33 PM
What's the benefit of running the push/pop (heh heh) on startup?
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 01:52:36 PM
What's the benefit of running the push/pop (heh heh) on startup?
Don't try to steal my joke.   :pissed:


I'm forcing some changes to some sysvars to keep everything running smoothly.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 01:54:50 PM
What's the benefit of running the push/pop (heh heh) on startup?
Don't try to steal my joke.   :pissed:


I'm forcing some changes to some sysvars to keep everything running smoothly.
No thievery.
Wait, so what does the push/pop do?
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: BlackBox on August 10, 2011, 01:57:33 PM
I'm running/loading a few things in S::Startup but that's between the PUSH/POP... I didn't think that would make a difference.  Maybe it does??

... (S::STARTUP) loads AFTER the (acad-pop-dbmod) at the end of ACAD.lsp

Also, the list above neglects this, but any .SCR file launched by your icon's startup switch loads AFTER (S::STARTUP).
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Matt__W on August 10, 2011, 02:00:52 PM
I'm running/loading a few things in S::Startup but that's between the PUSH/POP... I didn't think that would make a difference.  Maybe it does??

... (S::STARTUP) loads AFTER the (acad-pop-dbmod) at the end of ACAD.lsp

Also, the list above neglects this, but any .SCR file launched by your icon's startup switch loads AFTER (S::STARTUP).
Even though it's nestled snug between PUSH & POP?

*stands with hands on hips*  Well that makes no doggone sense.  Hmmpphh!!!
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: Lee Mac on August 10, 2011, 02:01:12 PM
Wait, so what does the push/pop do?

Effectively starts/stops the counter that records the number of modifications to the drawing:

Quote from: VLIDE Help Docs
acad-push-dbmod

Stores the current value of the DBMOD system variable

(acad-push-dbmod)

This function is used with acad-pop-dbmod to control the DBMOD system variable. You can use this function to change a drawing without changing the DBMOD system variable. The DBMOD system variable tracks changes to a drawing and triggers save-drawing queries.

This function is implemented in acapp.arx, which is loaded by default. This function pushes the current value of the DBMOD system variable onto an internal stack. To use acad-push-dbmod and acad-pop-dbmod, precede operations with acad-push-dbmod and then use acad-pop-dbmod to restore the original value of the DBMOD system variable.

Return Values

Always returns T.

Quote from: VLIDE Help Docs
acad-pop-dbmod

Restores the value of the DBMOD system variable to the value that was most recently stored with acad-push-dbmod

(acad-pop-dbmod)

This function is used with acad-push-dbmod to control the DBMOD system variable. The DBMOD system variable tracks changes to a drawing and triggers save-drawing queries.

This function is implemented in acapp.arx, which is loaded by default. This function pops the current value of the DBMOD system variable off an internal stack.

Return Values

Returns T if successful; otherwise, if the stack is empty, returns nil.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: alanjt on August 10, 2011, 02:03:54 PM
Wait, so what does the push/pop do?

Effectively starts/stops the counter that records the number of modifications to the drawing:

Quote from: VLIDE Help Docs
acad-push-dbmod

Stores the current value of the DBMOD system variable

(acad-push-dbmod)

This function is used with acad-pop-dbmod to control the DBMOD system variable. You can use this function to change a drawing without changing the DBMOD system variable. The DBMOD system variable tracks changes to a drawing and triggers save-drawing queries.

This function is implemented in acapp.arx, which is loaded by default. This function pushes the current value of the DBMOD system variable onto an internal stack. To use acad-push-dbmod and acad-pop-dbmod, precede operations with acad-push-dbmod and then use acad-pop-dbmod to restore the original value of the DBMOD system variable.

Return Values

Always returns T.

Quote from: VLIDE Help Docs
acad-pop-dbmod

Restores the value of the DBMOD system variable to the value that was most recently stored with acad-push-dbmod

(acad-pop-dbmod)

This function is used with acad-push-dbmod to control the DBMOD system variable. The DBMOD system variable tracks changes to a drawing and triggers save-drawing queries.

This function is implemented in acapp.arx, which is loaded by default. This function pops the current value of the DBMOD system variable off an internal stack.

Return Values

Returns T if successful; otherwise, if the stack is empty, returns nil.
Well damn, I guess I could have been a little less lazy and looked it up myself. Thanks.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: BlackBox on August 10, 2011, 02:07:03 PM
I'm running/loading a few things in S::Startup but that's between the PUSH/POP... I didn't think that would make a difference.  Maybe it does??

... (S::STARTUP) loads AFTER the (acad-pop-dbmod) at the end of ACAD.lsp

Also, the list above neglects this, but any .SCR file launched by your icon's startup switch loads AFTER (S::STARTUP).
Even though it's nestled snug between PUSH & POP?

*stands with hands on hips*  Well that makes no doggone sense.  Hmmpphh!!!

Correct, during ACAD.lsp you're simply adding items to BE loaded/executed during (S::STARTUP).

Instead, is it possible for you to simply load/execute the code in ACAD.lsp, or ACADDOC.lsp?

As I said, I also use both ACAD.lsp and ACADDOC.lsp at startup and open Drawing1 DBMOD = 0.

FWIW - You don't need to use Push/Pop to startup without a save prompt... you can use this instead:

Code: [Select]
(defun c:FOO ()
  "FOO")

(if (= 1 (getvar 'dwgtitled))
  (c:FOO))

(princ)

... That way, any DEFUNs you add are still able to be called, but will not cause Drawing1 to prompt for save. Just a thought.
Title: Re: DBMOD = 5 when I start AutoCAD
Post by: irneb on August 11, 2011, 09:19:10 AM
You could of course simply place the pop at the end of the S::Startup to have it run as late as possible. Of course if anything else appends onto the S::Startup as well that will get run after the pop. The /b switch only runs once per session though, so if you open another DWG all the usual suspects gets run again, without running the script.

This is a particularly prickly nettle! Even going through stuff like reactors can but make for more headaches. The "best" solution is not to change stuff inside the DWG through your startup routines, rather fix your templates correctly and run a script on existing files once and for all.