TheSwamp
Code Red => VB(A) => Topic started by: Kheilmann on June 15, 2006, 12:17:16 PM
-
I am testing each drawings that I open (actually there is no "on open" event, just an (Activate). So...each time I open or switch to a dwg my code runs.
The code just searches for a block and either replaces it with the latest version or just updates the year.
It works great except when I have several dwgs open with several layouts in each dwg.
I was trying to program a couple of flags but could not figure out how to get them to work...
1. Once a dwg is opened to assign a temporary flag to that dwg so that it will not run the code each time I switch to that dwg. all it will do is first check that flag and if True, exit sub, if false, continue.
2. To put my code in an event that will only run when a dwg is first opened......
Any ideas or thoughts,
Thanks is advance...
-
how about updateing the dwg on Close? Reason i ask is there is a close event. Then it would only run once, as the dwg closes
-
Here's the Wahr method of a DrawingOpen Event
Private Sub AcadDocument_BeginLisp(ByVal FirstLine As String)
If FirstLine = "s::startup" Then
'The drawing was just opened
End If
End Sub
-
Good idea Bob. Does that mean it looks for the file or the line where s::startup is?
-
everytime a lisp runs it checks the first line of the lisp to see if it's s::startup or not. I've had this running as a part of my "what the hell did I work on last week" dvb and haven't noticed any slowdown due to it running before that gets asked by someone.
-
very cool!!
-
Kheilmann, there are document level and application level events available.
The beginopen and endopen events are part of the latter.
Paste the following into your thisdrawing module
Private WithEvents AutoCAD As AcadApplication
Public Sub Acadstartup()
Set AutoCAD = Application
AutoCAD.WindowState = acMax
ThisDrawing.WindowState = acMax
End Sub
now clicking on AutocCAD in the object box you will see all the events available in the Procedure/Event Box (to its right).
Besides Bob's cool method I think you can also access the dwg attributes
-
Thanks Everyone for your input.
Bryco, I will try your method in a minute.
Bob, Your method works great, except now my lsp files don't seem to load anymore after the first drawing.
SDI = 0
Acaddocaslsp = 1
I commented out the Begin_Lisp procedure and now my commands seem to load OK.
Does anyone know of any conflicts?
I tried moving everything in my Acad.lsp file to the acaddoc.lsp and still nothing loaded after the 1st dwg.
???
-
Bryco, your method worked great. Though I had to use the EndOpen event as opposed to the BeginOpen.