Author Topic: Document Events and Timing  (Read 1874 times)

0 Members and 1 Guest are viewing this topic.

lanceg

  • Guest
Document Events and Timing
« on: August 14, 2007, 06:37:14 PM »
Hello, folks -- Thanks largely to Keith's help, I've gotten my VB application working with a VBA stub that sets up an instance of my class and terminates.  The event I'm programming fires when it's supposed to, and I'm happy.

The one "sticky wicket" is that I need to conditionally reset a system variable, depending on which command I'm catching.  It works every time EXCEPT the first time.  I've tried setting the system variable in my VB program, in the VBA stub, and in both places.  Both give the same result -- works every time except the first time.

I've created an ACAD.RX with ACVBA.ARX in it, and put the same code into ACAD.DVB that I have in my stub DVB program, just in case the order of program loading affects this, but no joy.  In other words, it doesn't seem to matter whether I autoload my program in ACAD.DVB or manually load it later, and the presence or absence of ACVBA.ARX (using vanilla ACAD 2007) also doesn't seem to matter.

What I'm trying to do is to use ATTREQ to suppress the DDATTE/ATTEDIT dialog box.  When I step through the code in the VBA stub, the request to reset the system variable happens before the DDATTE dialog pops up, yet it still pops up.

Another interesting factoid is that when the whole thing was done in VBA, this never happened.

With the variable being set in my DVB stub, it happens long before (in computer terms anyway) the VB program gets loaded, so I don't see why resetting ATTREQ doesn't affect the display of DDATTE/ATTEDIT -- the first time.  As I said, the rest of the time it works as expected.

What am I missing?

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Document Events and Timing
« Reply #1 on: August 15, 2007, 12:09:17 AM »
The timing is tricky enough in vba
For me the following works, whereas "VBAIDE" doesn't.
(I'm only talking about within vba)

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

lanceg

  • Guest
Re: Document Events and Timing
« Reply #2 on: August 15, 2007, 06:01:07 PM »
I had hoped that maybe BeginCommand would buy me enough extra time to head off the pesky DDATTE/ATTEDIT dialog, but it didn't.  I'm trying to work this in VBA, before I load the VB routine.

For now, I'm just going to set ATTREQ to 0 and see if that will work well enough.  It works in my application, but I want to be sure other block insertions (with attributes) work OK.  My app forces ATTEDIT to appear if the inserted object has attributes, so it may be.