TheSwamp
Code Red => VB(A) => Topic started by: ML on October 09, 2007, 01:51:22 PM
-
Hi
In my Acad.dvb file.
I have a Class module:
Dim AppEvents As New AppEventsClass
----------------------------------------
Sub acadstartup()
Set AppEvents.ACADApp = Application
End Sub
and a module:
Option Explicit
Public WithEvents ACADApp As AcadApplication 'Use with Application Event Examples
--------------------------
Private Sub ACADApp_AppActivate()
' I want this code to work on startup
End Sub
However, I noticed that the app level events are still not triggering
Can anyone tell me why this is happening?
THank you
Mark
-
What is it that you want to do upon startup?
-
I had to put my events in the This drawing module. BRB
edit: Added code
I must give someone else credit for this, but off the top of my head, I can't remember who helped me with this. Maybe Bryco ?? Anyway, I'll go look in a minute. Here is what they gave me to fix that app level event for end open
Option Explicit
Public WithEvents AutoCAD As AcadApplication
Sub App_StartMacro()
Set AutoCAD = ThisDrawing.Application
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "COMMANDLINE" Then
Set AutoCAD = ThisDrawing.Application
End If
End Sub
Private Sub AutoCAD_EndOpen(ByVal FileName As String)
ThisDrawing.SetVariable "INSUNITS", 1
ThisDrawing.SetVariable "OSNAPZ", 1
ThisDrawing.SetVariable "LAYEREVAL", 0
ThisDrawing.SetVariable "LAYERNOTIFY", 0
Dim strUser As String
strUser = UCase(Environ("USERNAME"))
Select Case strUser
Case "UA02038"
Case "UA03347"
Case Else
ThisDrawing.SendCommand "undefine" & vbCr & "BEDIT" & vbCr
End Select
End Sub
Public Sub AcadStartup()
Dim Preferences As AcadPreferences, intOsmode As Integer
Set Preferences = ThisDrawing.Application.Preferences
Dim strUser As String
strUser = UCase(Environ("USERNAME"))
Select Case strUser
Case "UA02038"
Preferences.Selection.PickFirst = True
intOsmode = 71
ThisDrawing.SetVariable "ORTHOMODE", 1
Case "UA03347"
Preferences.Selection.PickFirst = True
intOsmode = 19
Case Else
Preferences.Selection.PickFirst = True
intOsmode = 7
End Select
If intOsmode = 0 Then
ThisDrawing.SetVariable "osmode", 3
Else
ThisDrawing.SetVariable "osmode", intOsmode
End If
Application.Preferences.Output.AutomaticPlotLog = False
Application.Preferences.User.ADCInsertUnitsDefaultSource = acInsertUnitsInches
Application.Preferences.User.ADCInsertUnitsDefaultTarget = acInsertUnitsInches
ThisDrawing.SetVariable "OSNAPZ", 1
End Sub
End open wasn't available out of the box, but after these tweaks, it is
-
It was Bryco here (http://www.theswamp.org/index.php?topic=18666.msg228676#msg228676)