Author Topic: App Events not working  (Read 9392 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: App Events not working
« Reply #60 on: July 25, 2007, 01:27:27 PM »

Or by employing some lisp (which I rather not) we could undefine the line command

Then immediately afterwards, redefine it.

Mark

deegeecees

  • Guest
Re: App Events not working
« Reply #61 on: July 25, 2007, 01:29:54 PM »
Ok, if you just want to end the command try this:

Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim linjok As Integer
  If linjok = 0 Then
     If UCase(CommandName) = "LINE" Then
       MsgBox " We apologize for the inconvenience but AutoCAD has run out of lines", vbCritical
     End If
  End If
linjok = 1
[color=red]ThisDrawing.SendCommand vbCr & vbCr[/color]
End Sub

Jeff_M

  • King Gator
  • Posts: 3940
  • C3D user & customizer
Re: App Events not working
« Reply #62 on: July 25, 2007, 01:32:51 PM »
That is what this guy is suggesting but I very much like the way Jeff set me up. This guy gives a very good explanation of using the acad.rx, acad.dvb and acad (ac) vba.arx files in conjunction to achieve the same goal we are discussing here.
Mark, what that guy (Mike Tuersley) is doing is the same thing I do...except he placed the AcadStartup into ThisDrawing instead of it's own Module. I'm pretty sure that I got mine setup based on one of Mike's posts in the Adesk forums. :-)

Testing somemore....I tried changing the acad.dvb I posted for Mark to get the Application from Windows by modifying JUST this line:
Set AppEvents.ACADApp = Application
to this:
Set AppEvents.ACADApp = GetObject(, "AutoCAD.Application")

If that line is executed AFTER a drawing is open, all is well. However, since it is in the AcadStartup Sub, Acad attempts to load it before the Drawing is open and, evidently, before the AcadApplication is registered as being an Object with windows because it errors out with "Unable to Get the Object".

So it appears that App level events don't get autostarted in the first drawing...which I think is what Keith was saying.

Oh, and this worked for me for the Line command....
Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "LINE"
    MsgBox "No lines for you!", vbCritical
    SendKeys "{ESC}"
End If
End Sub
« Last Edit: July 25, 2007, 01:34:33 PM by Jeff_M »

deegeecees

  • Guest
Re: App Events not working
« Reply #63 on: July 25, 2007, 01:38:30 PM »
Oh, and this worked for me for the Line command....
Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "LINE"
    MsgBox "No lines for you[color=red], ONE YEAR![/color]", vbCritical
    SendKeys "{ESC}"
End If
End Sub

 :lmao:

ML

  • Guest
Re: App Events not working
« Reply #64 on: July 25, 2007, 02:34:38 PM »

Yes sir Jeff!

That is the ticket!

Thank you so much

"{ESC}" worked!

Also I do (for the most part) understand your (analogy).
Instead of saying GetObject, where are setting acadapp object to equal The acad app. + :?

Thank you very much

Mark

ML

  • Guest
Re: App Events not working
« Reply #65 on: July 26, 2007, 01:35:17 PM »

Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)

Select Case UCase(CommandName)
 Case Is = "LINE"
 MsgBox " We apologize for the inconvenience but AutoCAD has ran out of lines", vbCritical
 SendKeys "{ESC}"
End Select

End Sub


The above code is beautiful, freaking classic LOL
It makes programming all worth while  :-)
Hey, we can some fun once in a while, can't we?   :-D