.NET

Reply
Valued Mentor
409 Posts
28 Kudos
Registered: ‎01-27-2010
Post 1 of 4
Accepted Solution

How to check if a drawving is saved

231 Views, 3 Replies
01-23-2014 03:30 AM

Hi all.

i want to check if my file is saved or not. (already named). I need to do this for launch the command "-etransmit"

 

but i dont know how to do that.

No global var and found nothing here.

 

Thanks for your help.

If you check 'DBMOD' system variable, you can get the drawing modification status. Below is the sample code to check if drawing has been saved or not.

 

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
<CommandMethod("DrawingSaved")> _
Public Sub DrawingSaved()
Dim obj As Object = Application.GetSystemVariable("DBMOD")
'' Check the value of DBMOD, if 0 then the drawing has not been changed
If Not (System.Convert.ToInt16(obj) = 0) Then
If MsgBox("Do you wish to save this drawing?", _ 
MsgBoxStyle.YesNo, _
"Save Drawing") = MsgBoxResult.Yes Then Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
acDoc.Database.SaveAs(acDoc.Name, True, DwgVersion.Current, _
acDoc.Database.SecurityParameters) End If End If End Sub

 

You can find details about DBMOD variable in below location:

http://exchange.autodesk.com/autocad/enu/online-help/search#WS1a9193826455f5ffa23ce210c4a30acaf-50a8.htm

 

Distinguished Mentor
582 Posts
91 Kudos
Registered: ‎04-11-2010
Post 2 of 4

Re: How to check if a drawving is saved

01-23-2014 05:50 AM in reply to: AubelecBE

Hi,

 

I think a combination of "DWGTITLED" and "DBMOD" system variables  should provide you the information needed to etransmit or to not etransmit.

 

Gaston Nunez

Mentor
231 Posts
30 Kudos
Registered: ‎11-09-2012
Post 3 of 4

Re: How to check if a drawving is saved

01-23-2014 08:07 AM in reply to: AubelecBE

If you check 'DBMOD' system variable, you can get the drawing modification status. Below is the sample code to check if drawing has been saved or not.

 

Imports Autodesk.AutoCAD.ApplicationServices 
Imports Autodesk.AutoCAD.DatabaseServices 
Imports Autodesk.AutoCAD.Runtime 
<CommandMethod("DrawingSaved")> _ 
Public Sub DrawingSaved() 
Dim obj As Object = Application.GetSystemVariable("DBMOD") 
'' Check the value of DBMOD, if 0 then the drawing has not been changed 
If Not (System.Convert.ToInt16(obj) = 0) Then 
If MsgBox("Do you wish to save this drawing?", _                 
MsgBoxStyle.YesNo, _
"Save Drawing") = MsgBoxResult.Yes Then Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
acDoc.Database.SaveAs(acDoc.Name, True, DwgVersion.Current, _
acDoc.Database.SecurityParameters) End If End If End Sub

 

You can find details about DBMOD variable in below location:

http://exchange.autodesk.com/autocad/enu/online-help/search#WS1a9193826455f5ffa23ce210c4a30acaf-50a8...

 

Valued Mentor
409 Posts
28 Kudos
Registered: ‎01-27-2010
Post 4 of 4

Re: How to check if a drawving is saved

01-24-2014 03:20 AM in reply to: mzakiralam

Thanks, work fine.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post