Author Topic: ACAD App Events  (Read 1915 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
ACAD App Events
« on: October 09, 2007, 01:51:22 PM »

Hi

In my Acad.dvb file.

I have a Class module:

Dim AppEvents As New AppEventsClass
----------------------------------------
Code: [Select]
Sub acadstartup()

 Set AppEvents.ACADApp = Application

End Sub

and a module:

Code: [Select]
Option Explicit

Public WithEvents ACADApp As AcadApplication    'Use with Application Event Examples

--------------------------
Code: [Select]
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

Guest

  • Guest
Re: ACAD App Events
« Reply #1 on: October 09, 2007, 01:52:28 PM »
What is it that you want to do upon startup?

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: ACAD App Events
« Reply #2 on: October 09, 2007, 02:19:58 PM »
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
Code: [Select]
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
« Last Edit: October 09, 2007, 02:21:56 PM by CmdrDuh »
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: ACAD App Events
« Reply #3 on: October 09, 2007, 02:23:03 PM »
It was Bryco here
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)