Author Topic: Before DWG Open Event Handler  (Read 1573 times)

0 Members and 1 Guest are viewing this topic.

TJK44

  • Guest
Before DWG Open Event Handler
« on: February 02, 2018, 02:26:08 PM »
Hi,

Does anyone know the event to use (if one exists) that will trigger prior to when AutoCAD checks the xref status?

I want to do some custom xref resolving prior to it prompting to input the location of a missing xref. I tried the below events, but none fired prior to the prompt appearing.

Code - Visual Basic: [Select]
  1. AddHandler Application.DocumentManager.DocumentCreated, AddressOf Application_DocumentCreated
  2. AddHandler Application.DocumentManager.DocumentCreateStarted, AddressOf Application_DocumentCreateStarted
  3. AddHandler Application.DocumentManager.DocumentToBeActivated, AddressOf Application_DocumentToBeActivated
  4. AddHandler Application.DocumentManager.DocumentBecameCurrent, AddressOf Application_DocumentBecameCurrent
  5. AddHandler Application.DocumentManager.CurrentDocument.BeginDwgOpen, AddressOf Application_BeginDwgOpen
  6. AddHandler Application.DocumentManager.CurrentDocument.EndDwgOpen, AddressOf Application_EndDwgOpen

Thanks,

Ted
« Last Edit: February 02, 2018, 04:35:24 PM by TJK44 »

TJK44

  • Guest
Re: Before DWG Open Event Handler
« Reply #1 on: February 02, 2018, 04:29:58 PM »
Got it working as desired, had to use two event handlers.

First this...

Code - Visual Basic: [Select]
  1. AddHandler Application.DocumentManager.DocumentCreateStarted, AddressOf Application_DocumentCreateStarted

...then...

Code - Visual Basic: [Select]
  1. Private Sub Application_DocumentCreateStarted(sender As Object, e As DocumentCollectionEventArgs)
  2.      AddHandler e.Document.BeginDwgOpen, AddressOf Document_BeginDwgOpen
  3. End Sub
« Last Edit: February 02, 2018, 04:35:55 PM by TJK44 »