VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Beginsave/Endsave

25 REPLIES 25
Reply
Message 1 of 26
Anonymous
595 Views, 25 Replies

Beginsave/Endsave

I think my brain is probably just in weekend mode already, this should be so easy but I just can't see it.

What I want to do is to is to determine whether a drawing was successfully saved. If it was not saved, it's name is removed from a list (Excel).

So I import the list from Excel into an array and sort it. And then I'm stuck. Sure I can find out if the number of the drawing is in the list, but that doesn't help me.

What parameter can I use to test whether the drawing has been saved or not?

Also, I'm guessing I want to use the Endsave event, as I want to be sure it has been saved (or not).
25 REPLIES 25
Message 21 of 26
Anonymous
in reply to: Anonymous

Hi Wouter
I am curious, what is the DBMOD variable?

Tertia,
We all get bogged down, unfortunately, that is how it goes sometimes; this is one of the reasons I have avoided management for so long; I figure, if I can make decent money, then why deal with it.
On a support level, I totally understand.

I have had some free time lately and have been more active in the forums but as of next week, I may be much busier again.

I don't think it is real hard to do what you need to do but it would be easier if I , or whoever is helping you can see the spread sheet, etc.

Also, the acad.dvb files is really essential to writing good event procedures, so I would def. look into that as well.
i think that I shared mine with you?

When you get time, hopefully we will be able to help you

ML
Message 22 of 26
Anonymous
in reply to: Anonymous

Oh yeah, the DBMOD in EndSave does the trick! Thanks again, Wouter.

I declared varTestSaved and used this line:
varTestSaved = ThisDrawing.GetVariable("DBMOD")
From there I can replace the drawing number into the picklist.

I've got an instance where I think the FSO code will come in very useful, though. It might work better than my current, rather long-winded method.

Just for the sake of completeness, I need to answer Norman's contribution.

1) The drawing is removed from the picklist the moment one draftsman selects it, so it can't be selected by another draftsman. I agree, these guys are pretty allergic to a "Save" button, so I dare not risk leaving a number as "available" until the user eventually gets around to saving it. Which is why I need to only replace the number if the user decides not to save. (This, generally, happens by accidentally closing the program without saving.)

2) You're right, if I could use just one spreadsheet, and indicate somewhere on it that the drawing is in use, it would be easier. Unfortunately the spreadsheet in use is a Drawing register, and these things get updated and revved up at times. So I need to also update columns like "Drawn By" on new revisions of the Drawing Register, which implies I have to have a record of the used drawings to be able to update new revs and keep the integrity of which numbers have been used, regardless of which Drawing register is selected. It is also rather likely that, if there are a few revisions of the Drawing register in the folder, someone will inevitably select an older revision.

Oh boy, the effort one has to go to in order to protect users from themselves.

ML, I would share my code, but later will be better, it is currently riddled with commented-out text, msgbox'es to myself for debugging, and not exactly well documented.

Thanks again, all!
Message 23 of 26
Anonymous
in reply to: Anonymous

hey ml0940,

(copy from autocad help)

DBMOD = System Variable
(Read-only)
Type: Integer
Saved in: Not-saved
Initial value: 0


Indicates the drawing modification status. The setting is stored as a bitcode using the sum of the following values:

1 = Object database modified
4 = Database variable modified
8 = Window modified
16 = View modified
32 = Field modified

The DBMOD value is reset to 0 when you save the drawing.
Message 24 of 26
Anonymous
in reply to: Anonymous

Wouter
Thank you very much for the code; I have not heard of that variable, I will look at it for sure.

Tertia, I'm not sure that you ever answered this question still; are you using the acad.dvb file? I will assume that the answer is yes because we are still talking about The Begin/Save Event. Again, there is a Begin/Save event in each drawing but to use it globally, for all drawings that are opened anytime, then you will likely need to capture the app level event and to do that will require The ACAD.dvb a little bit of code to get The With Events Class from THe Acad.dvb.
That is why I posted mine.

Private Sub AcadDocument_BeginSave(ByVal FileName As String)

End Sub

Yes, with FSO, there is a whole lot you can do; I just used FSO with my End_Plot event so that we can log the date, time and username of each plot that is sent to the plotter. For now, I append a text file with each plot; if necessary, I can send that infor to a spread sheet.
If interested, here is that code, using FSO:

Private Sub ACADApp_EndPlot(ByVal DrawingName As String)
Dim FSO As Variant, WshNetwork As Variant
Dim Username As Variant, PltLogFile As Variant
Dim Dwgname As String, Fn As String
Dim CurrDate As Variant

Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = CreateObject("WScript.Network")

Username = WshNetwork.Username
Dwgname = ThisDrawing.Name
CurrDate = Date
Fn = "C:\Documents and Settings\" & Username & "\Desktop\Plotlog.txt"

If (FSO.FileExists(Fn)) Then
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set PltLogFile = FSO.OpenTextFile(Fn, 8, True)
PltLogFile.WriteLine "The user " & Username & " has requested to plot drawing " & Dwgname & _
" on " & CurrDate
PltLogFile.Close
Else
Debug.Print "The file " & Fn & " does not exist"
'MsgBox "The file " & Fn & " does not exist"
Exit Sub
End If
End Sub

Very simple code but great results.

Scripting code is very handy when mixed with VBA

ML
Message 25 of 26
Anonymous
in reply to: Anonymous

Nice one, ML, thanks. Storing it for future reference.

Oh, and I discovered using the DMBOD in the StartClose event is actually the 100% perfect solution for my problem.

And it is simple. Very simple. As I thought, some weeks ago, also on a Friday.
Message 26 of 26
Anonymous
in reply to: Anonymous

Great!
I was never even sure if you were using the acad.dvb; I guess you are.
Well, I am glad that you figured it out 🙂
Forums are not always the best to try to resolve complex problems. At least it seemed complex as to how you were explaining it.

Glad you liked the script, it was pretty cut and dry.
I just need to capture the active plotterr and it will be good 🙂

Stay in touch
Mark

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost