Author Topic: GetSystemVariable from a CommandMethod.Session  (Read 2667 times)

0 Members and 1 Guest are viewing this topic.

Odoshi

  • Guest
GetSystemVariable from a CommandMethod.Session
« on: December 27, 2011, 08:56:21 AM »
Hi,

GetSystemVariable is not returning anything when CommandMethod is Session. Works for CommandMethod Modal.

Is this the correct behavior? The command does a lot, including opening several drawings, calling SetSystemVariable as well as running LISP from Application.Invoke.

Currently it is failing on:

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add("C:\my-tplate.dwt")

Any suggestions on the CommandMethod flags to use?

Thanks,
Mike

Odoshi

  • Guest
Re: GetSystemVariable from a CommandMethod.Session
« Reply #1 on: December 27, 2011, 09:38:37 AM »
OK, here's what it was:

Calling Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)

Better to just use frm.ShowDialog()

Thanks,
Mike

Odoshi

  • Guest
Re: GetSystemVariable from a CommandMethod.Session
« Reply #2 on: December 27, 2011, 10:29:12 AM »
Just to follow up,

SetSystemVariable does not seem to be working when CommandFlag is Session. Could anyone else confirm?


Thanks,
Mike

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: GetSystemVariable from a CommandMethod.Session
« Reply #3 on: December 30, 2011, 08:55:08 PM »
Yes,
I get Autodesk.AutoCAD.Runtime.Exception: eInvalidInput when using SetSystemVariable from a Session ie TestS1.

I don't have an issue with GetVariable ... what are you trying to do ?

using:
Code - Text: [Select]
  1. using Autodesk.AutoCAD.Runtime;
  2. using Autodesk.AutoCAD.ApplicationServices;
  3.  
  4. [assembly: CommandClass(typeof(SetVariableTester.MyCommands))]
  5.  
  6. namespace SetVariableTester
  7. {
  8.     public class MyCommands
  9.     {
  10.         [CommandMethod("TestD1") ]
  11.         public void MyDocumentCmd1()
  12.         {
  13.             Application.SetSystemVariable("CLAYER", "0");
  14.         }
  15.         [CommandMethod("TestS1", CommandFlags.Session)]
  16.         public void MySessionCmd1()
  17.         {
  18.             Application.SetSystemVariable("CLAYER", "0");
  19.         }
  20.         [CommandMethod("TestS2",  CommandFlags.Session)]
  21.         public void MySessionCmd2()
  22.         {
  23.             Application.ShowAlertDialog(Application.TryGetSystemVariable("CLAYER").ToString());
  24.         }
  25.     }
  26. }

Which variable are you trying to set ??
Some can be set using properties of the Database for the ActiveDocument
eg:
Code - C#: [Select]
  1. Application.DocumentManager.MdiActiveDocument.Database.Orthomode = true;

Some of your post has nothing to do with SystemVariables .... you may need to clarify what you want.

Regards
Kdub
« Last Edit: December 31, 2011, 02:54:18 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: GetSystemVariable from a CommandMethod.Session
« Reply #4 on: December 30, 2011, 09:00:13 PM »
< .. >
Currently it is failing on:

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add("C:\my-tplate.dwt")


How is it failing ?
What is the exception ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Odoshi

  • Guest
Re: GetSystemVariable from a CommandMethod.Session
« Reply #5 on: December 31, 2011, 11:01:14 AM »
I've done away with the Session flag, so that's no longer an issue.

I also moved to a palette, so DocumentManager.Add is now working.

Thanks for the replies,
Mike