Author Topic: SysVarChanged Event?  (Read 7560 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #15 on: January 11, 2008, 05:10:48 PM »
try that.  Also, there is nothing special about N, I just used a single letter to capture the string
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 #16 on: January 11, 2008, 05:12:06 PM »
Well,
Right now I just want it to recognize what workspace I switched to.
It is kind of bizarre but it seems that the toolbars on the last workspace that I have active get screwy after I close ACAD.
So, I decided to try something; I made a workspace called blank.

If I first switch to blank, then close; my Map Classic workspace is fine when I re start CAD.

I have tried a number of things; I have a feeling this is another one of theses beautiful anomalies of The Cui s

So, for now, I just want it to recognize Map Classic or blank on the switch.

Pseudo:
If The system variable (wscurrent) is blank, then AutoCAD.close

Mark

ML

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

Yes sir!
You the man!

I had a feeling I needed to use the getvariable method, just wasn't sure how to work it

Thank you sir!

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #18 on: January 11, 2008, 05:18:40 PM »
Now if you have more than 2 workspaces, nest another SelectCase to check which 1 is loaded.  For just 2, you can use the if then else and make 1 of 2 things happen
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 #19 on: January 11, 2008, 05:20:03 PM »

Well they are all loaded as they are all part of the main cui file; so I would use the case for the respective workspace that I need to work on.

Thank you sir! :)


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: SysVarChanged Event?
« Reply #20 on: January 11, 2008, 05:25: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")
   Select Case N
   Case is = "Map Classic"
   MsgBox "Do something #1"
   Case is = "Not Map Classic"
   MsgBox "Do something #2"
   Case is = "3rd Choice"
   MsgBox "Do something #3"
 End Select
 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 #21 on: January 11, 2008, 05:25:35 PM »
Actually you are right CM
I would use the CASE statement (likely) for the different system variables and the End If conditions for the different workspaces

Mark

ML

  • Guest
Re: SysVarChanged Event?
« Reply #22 on: January 11, 2008, 05:27:39 PM »

ahhhh
better yet LOL :)

Thank you!


I do try to lean towards Case statements over multiple End If statements.

The system variable change event can be pretty useful

Mark

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: SysVarChanged Event?
« Reply #23 on: January 11, 2008, 05:33:03 PM »
FWIW, David & Mark, there is no need for the N variable......the newVal variable returned by the Event holds the value of the Sysvar of interest.
Code: [Select]
Private Sub ACADApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
 Select Case SysvarName
  Case Is = "WSCURRENT"
   Select Case newVal
   Case is = "Map Classic"
   MsgBox "Do something #1"
   Case is = "Not Map Classic"
   MsgBox "Do something #2"
   Case is = "3rd Choice"
   MsgBox "Do something #3"
 End Select
 End Select
End Sub
edit: changed name to value as to what is returned.
« Last Edit: January 11, 2008, 05:36:43 PM by Jeff_M »

ML

  • Guest
Re: SysVarChanged Event?
« Reply #24 on: January 11, 2008, 05:35:19 PM »

Yes, this works very well

Code: [Select]
Select Case SysvarName
   Case Is = "WSCURRENT"
    Dim WS As String
    WS = GetVariable("WSCURRENT")
  Select Case WS
    Case Is = "Blank"
    MsgBox "Do something"
  End Select
 End Select

WS = GetVariable ("WSCURRENT")

Then we can go on and on:

FD = GetVariable ("FILEDIA")

SDI = GetVariable ("SDI")

Excellent!

Thanks CM!

Mark

ML

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

Oh yes!
Thanks Jeff!

This is where we began actually, I just could not get anything to happen
Actually both methods work just fine but you are right Jeff; there is no need for the get variable;
They have already accounted for that with newval

Thank you.

Mark

ML

  • Guest
Re: SysVarChanged Event?
« Reply #26 on: January 11, 2008, 05:57:36 PM »

It's a bit bizarre but think of my workspace Blank as
Application.quit

Actually I will rename blank to Exit

So, now I simply doing this:

Code: [Select]
Select Case SysvarName
  Case Is = "WSCURRENT"
   Select Case newVal
    Case Is = "Exit"
     Application.Quit
     Exit Sub
   End Select
 End Select

So, when workspace Exit is activated, exit AutoCAD

It is weird but it definitely doing what I needed.

My toolbars in Workspace Map General are now being retained.

ACAD (at least Map Enabled) does not like something about the last workspace active on exit; so I just made a dummy one I am using to exit with.

It is kind of nifty; it is like a workspace change event.

Thanks guys!

Mark