Message 1 of 2
AcadDocument_EndCommand
Not applicable
01-10-2008
02:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I’m missing something somewhere; I have been initializing a number of VBA-Programs in my ACADDOC.LSP file and I am trying to get around a problem where, if a user selects multiple DWG files and then hits the Enter key some of the files will get locked up (Task-manager ‘kill-the-process’ level locked up) at a :Macro name Command Line Prompt.
So I thought I’d initialize then with the ACAD.DVB file and the ACADStartup() function (Which I understand only executes when AutoCAD first starts up) as I have been meaning to do for some time now anyway (see code below).
So I have set up an ACAD.RX file (one line: ACVBA.ARX, if AutoCAD 2004 + (or) ACADVBA.ARX if <= AutoCAD 2002) and I removed all my VL-VBARUN functions from my ACADDOC.LSP file, setup an ACADDOCUMENT_ENDCOMMAND function to call another sub to use the Sendcommand function to create my Command Prompt commands (and to do a command line diagnostic prompt I used to do in the ACADDOC file) the results are confusing.
When AutoCAD is initiated from a Shortcut everything executes well.
When I double click on a file to startup AutoCAD everything works fine.
If I select a group of files and hit enter to start up AutoCAD everything works fine
If I open an existing file from within and active session from the Files Pull-Down menu everything works fine; but if I open an existing file from within and active session from the command line my VBA does not initialize (even though a test string in the VBAIDE immediate window driven by a debug.print function clearly shows that the active command was/is OPEN).
If I create a NEW file everything initializes fine but QNEW will not.
I can have two locked up drawings (cannot get back to the command prompt) while within another drawing I am able to work without a problem in the same AutoCAD session…I can switch between the locked up files and the ‘good’ files with the windows pull-down but the command line is inaccessible in the locked files.
Clearly I’ve got something bizarre going on here but I am not able to discern where the pattern is (much less isolate the problem).
Any help is wholeheartedly solicited and thanks in advance.
Code Follows:
Sub ACADStartup()
Call AcadApplication.LoadDVB("Q:\LISP06\DPROPS.DVB")
Call AcadApplication.LoadDVB("Q:\LISP06\NewLib.DVB")
Call AcadApplication.LoadDVB("Q:\LISP06\Newolyr.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\Repather.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\newupdate.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\Savelocal.DVB")
Call AcadApplication.RunMacro("init")
Call AcadApplication.RunMacro("savelocal")
Call defunstuff
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If UCase(CommandName) Like "OPEN"
Or UCase(CommandName) Like "NEW"
Or UCase(CommndName) Like "QNEW" Then
Debug.Print "This drawing just finished a " & CommandName & " command. Compare = T"
Call defunstuff
Else
Debug.Print "This drawing just finished a " & CommandName & " command. Compare = F"
End If
End Sub
Public Sub defunstuff()
Dim slispdef As String
slispdef = "(vl-load-com)" & vbCr & _
"(Defun C:LIB ()(vl-vbarun " & Chr(34) & "Lib" & Chr(34) & "))" & _
vbCr & "(Defun C:RP ()(vl-vbarun " & Chr(34) & "xtest" & Chr(34) & "))" & _
vbCr & "(Defun C:ODP ()(vl-vbarun " & Chr(34) & "DP" & Chr(34) & "))" & _
vbCr & "(Defun C:OLYR ()(vl-vbarun " & Chr(34) & "OLYR" & Chr(34) & "))" & vbCr
SendCommand slispdef
ThisDrawing.Utility.Prompt vbLf & ThisDrawing.GetVariable("USERS1") & _
"Otak VBA Code Initialized..." & vbLf
End Sub
So I thought I’d initialize then with the ACAD.DVB file and the ACADStartup() function (Which I understand only executes when AutoCAD first starts up) as I have been meaning to do for some time now anyway (see code below).
So I have set up an ACAD.RX file (one line: ACVBA.ARX, if AutoCAD 2004 + (or) ACADVBA.ARX if <= AutoCAD 2002) and I removed all my VL-VBARUN functions from my ACADDOC.LSP file, setup an ACADDOCUMENT_ENDCOMMAND function to call another sub to use the Sendcommand function to create my Command Prompt commands (and to do a command line diagnostic prompt I used to do in the ACADDOC file) the results are confusing.
When AutoCAD is initiated from a Shortcut everything executes well.
When I double click on a file to startup AutoCAD everything works fine.
If I select a group of files and hit enter to start up AutoCAD everything works fine
If I open an existing file from within and active session from the Files Pull-Down menu everything works fine; but if I open an existing file from within and active session from the command line my VBA does not initialize (even though a test string in the VBAIDE immediate window driven by a debug.print function clearly shows that the active command was/is OPEN).
If I create a NEW file everything initializes fine but QNEW will not.
I can have two locked up drawings (cannot get back to the command prompt) while within another drawing I am able to work without a problem in the same AutoCAD session…I can switch between the locked up files and the ‘good’ files with the windows pull-down but the command line is inaccessible in the locked files.
Clearly I’ve got something bizarre going on here but I am not able to discern where the pattern is (much less isolate the problem).
Any help is wholeheartedly solicited and thanks in advance.
Code Follows:
Sub ACADStartup()
Call AcadApplication.LoadDVB("Q:\LISP06\DPROPS.DVB")
Call AcadApplication.LoadDVB("Q:\LISP06\NewLib.DVB")
Call AcadApplication.LoadDVB("Q:\LISP06\Newolyr.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\Repather.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\newupdate.dvb")
Call AcadApplication.LoadDVB("Q:\LISP06\Savelocal.DVB")
Call AcadApplication.RunMacro("init")
Call AcadApplication.RunMacro("savelocal")
Call defunstuff
End Sub
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If UCase(CommandName) Like "OPEN"
Or UCase(CommandName) Like "NEW"
Or UCase(CommndName) Like "QNEW" Then
Debug.Print "This drawing just finished a " & CommandName & " command. Compare = T"
Call defunstuff
Else
Debug.Print "This drawing just finished a " & CommandName & " command. Compare = F"
End If
End Sub
Public Sub defunstuff()
Dim slispdef As String
slispdef = "(vl-load-com)" & vbCr & _
"(Defun C:LIB ()(vl-vbarun " & Chr(34) & "Lib" & Chr(34) & "))" & _
vbCr & "(Defun C:RP ()(vl-vbarun " & Chr(34) & "xtest" & Chr(34) & "))" & _
vbCr & "(Defun C:ODP ()(vl-vbarun " & Chr(34) & "DP" & Chr(34) & "))" & _
vbCr & "(Defun C:OLYR ()(vl-vbarun " & Chr(34) & "OLYR" & Chr(34) & "))" & vbCr
SendCommand slispdef
ThisDrawing.Utility.Prompt vbLf & ThisDrawing.GetVariable("USERS1") & _
"Otak VBA Code Initialized..." & vbLf
End Sub