Check if user has done something after opening a drawing.

Check if user has done something after opening a drawing.

SRSDS
Advisor Advisor
545 Views
4 Replies
Message 1 of 5

Check if user has done something after opening a drawing.

SRSDS
Advisor
Advisor

I would like a to know if the user has done something has occurred after a drawing has been opened.

I can't figure out a location to store a boolean variable that:

Does not modify the document's database. If the database is modified on opening the drawing thinks it needs saving.

Is affected by the undo command, which Document.UserData isn't.

0 Likes
Accepted solutions (2)
546 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted solution

You may want to check the system variable "DBMod":

normanyuan_0-1715435536560.png

You can also call Document.PopDbmod()/PushDbmod() to arbitrarily set the drawing modification status, if necessary.

 

See this documentation on these 2 methods (it is for AutoLisp, but the remark/code sample are straightforward to follow):

https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-1B34A525-A881-42A8-BD07-865CA685F33B 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

SRSDS
Advisor
Advisor

Hi Normal,

I was aware of the DBMOD system variable but never thought to try and change it.

I've just tried these which don't seem to work. That would be brilliant if I could achieve it.

        Application.DocumentManager.MdiActiveDocument.PopDbmod()
        Application.DocumentManager.MdiActiveDocument.PushDbmod()
        Application.SetSystemVariable("DBMOD", 0)

 

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

If you read the LISP code sample referred in the link provided in my previous reply, you should realize the correct way to use PushDbmod()/PopDbmod() method:

 

You call PushDbmod() first, which is equivalent to save the DBMOD value; then you can go ahead to do your work with the drawing, which might result in the DBMOD value change accordingly; then you call PopDbmo() to remove the changed DBMO value caused by your code and restore the value when PushDbmod() is called.

 

So, you would use code like:

 

var dwg=.....MdiActiveDocument;

try

{

    dwg.PushDbmod();

   DoMyWorkToChangeThingsInDwg(dwg);

}

finally

{

    dwg.PopDbmod();

}

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

SRSDS
Advisor
Advisor

Thank you! I didn't think there would be a solution. That's great.

0 Likes