Author Topic: SysVarChanged Event?  (Read 7559 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
SysVarChanged Event?
« on: January 11, 2008, 12:36:03 PM »

Has anyone ever programmed a system variable change event?
I seem to be missing something
I am trying to do something if ACAD successfully recognizes that I have changed my workspace.
Any ideas?

Thanks!
Mark

Code: [Select]
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
 Select Case SysvarName
  Case Is = "wscurrent"
  Case newVal = "Test"
  MsgBox "Anything?"
 End Select
End Sub

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: SysVarChanged Event?
« Reply #1 on: January 11, 2008, 01:40:53 PM »
SysvarName will always be in CAPS so your test fails. Also, you cannot set the newValue, this is a value passed TO the handler telling you what the value has been changed to.

Try this (not tested as I'm not running 2008 at the moment)
Code: [Select]
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
 Select Case SysvarName
  Case Is = "WSCURRENT"
       Msgbox "New value for WSCURRENT is " & newVal
 End Select
End Sub

ML

  • Guest
Re: SysVarChanged Event?
« Reply #2 on: January 11, 2008, 02:01:14 PM »

Hey Jeff

That is not doing it either. hummmmm

Any other ideas?

THanks!

Mark

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: SysVarChanged Event?
« Reply #3 on: January 11, 2008, 02:19:42 PM »
Mark,
I had to shutdown Acad and restart it to get the Event to start working. Just tested the code I posted in C3D2008 and this is the result:

ML

  • Guest
Re: SysVarChanged Event?
« Reply #4 on: January 11, 2008, 02:29:48 PM »
Ahhhhhh

Good point or just run the startup macro again that is accessing the acad object.

Yes sir! That did it!

Cool! Thanks Jeff!

Mark


ML

  • Guest
Re: SysVarChanged Event?
« Reply #5 on: January 11, 2008, 03:25:52 PM »

Jeff
Here is a fun one for you that I wrote a few years back
A lot of fun! LOL

Put this on your Begin Commnad Event

Mark

Code: [Select]
Select Case CommandName
 Case Is = "LINE"
 MsgBox "We apologize for the inconvenience but AutoCAD has temporarily ran out of lines" & vbCrLf & _
 "Please try again", vbCritical
 SendKeys "{ESC}"
End Select

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #6 on: January 11, 2008, 04:17:49 PM »
I actually use that to prevent my users from using BEdit
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)

ML

  • Guest
Re: SysVarChanged Event?
« Reply #7 on: January 11, 2008, 04:56:10 PM »

You mean The
Command Change Event?

You don't use the out of lines code, do yeah? LOL
That code is great is someone screws with you.

Well, I told you the story.

I got that SOB!  LOL

Mark

ML

  • Guest
Re: SysVarChanged Event?
« Reply #8 on: January 11, 2008, 04:58:17 PM »

Actually I am still having some trouble here;
I (we) got the the msgbox to return the workspace on the system Variable change but
I am now trying to get it to recognize a specifically named Workspace

Not sure what I am missing  hmmmmmmm

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #9 on: January 11, 2008, 04:59:16 PM »
Post what you have so far
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: SysVarChanged Event?
« Reply #10 on: January 11, 2008, 05:00:44 PM »
Code: [Select]
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim strUser As String
      Select Case UCase(CommandName)
      Case Is = "BEDIT"
            strUser = UCase(Environ("USERNAME"))
            Select Case strUser
            Case "UA02038"
            Case "UA03347"
            Case Else
                  MsgBox "B-Edit has been removed," & vbCrLf & _
                         "Contact Ron Roach or David Hall", vbCritical
                  SendKeys "{ESC}"
            End Select
      Case Is = "-BEDIT"
            strUser = UCase(Environ("USERNAME"))
            Select Case strUser
            Case "UA02038"
            Case "UA03347"
            Case Else
                  MsgBox "B-Edit has been removed," & vbCrLf & _
                         "Contact Ron Roach or David Hall", vbCritical
      '  SendKeys "{ESC}"
                  ThisDrawing.SendCommand "bclose" & vbCr
            End Select
      Case Is = "COMMANDLINE"
            Set AutoCAD = ThisDrawing.Application
      End Select
End Sub
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)

ML

  • Guest
Re: SysVarChanged Event?
« Reply #11 on: January 11, 2008, 05:03:17 PM »

ahhhhh

I suck with this stuff LOL
Here is all I have so far CM

Thanks!
Mark

Code: [Select]
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
 Select Case SysvarName
  Case Is = "WSCURRENT"
  Case Is = "Map Classic"
   MsgBox "Do something!"
 End Select
End Sub

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #12 on: January 11, 2008, 05:05:37 PM »
what are you trying to do?  I need a little more info
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)

ML

  • Guest
Re: SysVarChanged Event?
« Reply #13 on: January 11, 2008, 05:05:42 PM »

Cool! Looks good!

I bet your users love this:

Code: [Select]
MsgBox "B-Edit has been removed," & vbCrLf & _
                         "Contact Ron Roach or David Hall", vbCritical


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #14 on: January 11, 2008, 05:10:08 PM »
Code: [Select]
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
 Select Case SysvarName
  Case Is = "WSCURRENT"
  Dim N As String
   N = GetVariable("WSCURRENT")
   If N = "Map Classic" Then
   MsgBox "Do something"
   End If
 End Select
End Sub
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)