Author Topic: Get all AutoCAD system variables  (Read 4968 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Get all AutoCAD system variables
« on: November 11, 2011, 06:24:20 AM »
How can I get all system variables of AutoCAD? I want get it as IEnumerable.
If it impossible now, then it would be very good, if in.Net API such properties were marked with special attribute, for example AcVariableAttribute. Then through reflection it would be possible to receive the all system variables of AutoCAD.

I hope that you can understand that I have written. Just in case I set an example:

Code: [Select]
//==================================
public class AcVariableAttribute : Attribute {       
    public string FullName { get; private set; }
    public string HelpPage { get; private set; }
    public AcVariableAttribute(string fullName, string helpPage) {
        FullName = fullName;
        HelpPage = helpPage;
    }
}
//==================================

I show attribute application on an example of class Database (for AutoCAD 2009):

Code: [Select]
//==================================
[Wrapper("AcDbDatabase")]
public sealed class Database : RXObject {
    //...
    [AcVariable("USERR1", @"WS1a9193826455f5ffa23ce210c4a30acaf-4e0e-reference.htm")]
    public double Userr1 { get; set; }
    //...
}
//==================================

Thank you.

kaefer

  • Guest
Re: Get all AutoCAD system variables
« Reply #1 on: November 11, 2011, 07:29:44 AM »
How can I get all system variables of AutoCAD?

Short of enumerating them all by yourself, could you try parsing 'sysvdlg.dat' from the Express Tools?

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Get all AutoCAD system variables
« Reply #2 on: November 11, 2011, 07:42:09 AM »
Short of enumerating them all by yourself, could you try parsing 'sysvdlg.dat' from the Express Tools?
I haven't understood your answer. Me interests, as it to make through.Net API. I don't want to receive so:
Code: [Select]
Command: SETVAR
Enter variable name or [?]:?
Enter variable (s) to list <*>: *

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Get all AutoCAD system variables
« Reply #3 on: November 11, 2011, 09:18:36 AM »
Seems like I have seen using logfile with "setvar ? *" and also setting 'QAFLAGS' to 2 to execute command without hitting enter multiple times.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Get all AutoCAD system variables
« Reply #4 on: November 14, 2011, 10:40:30 AM »
Don't newer versions of AutoCAD keep system variables in the registry, including the ability to create your own with your own enumerated settings e.g. HKLM\Software\Autodesk\AutoCAD\XXXXX\xxxxx\Variables.  Should be able to query registry keys to pick them up, including application and user custom ones.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

kaefer

  • Guest
Re: Get all AutoCAD system variables
« Reply #5 on: November 14, 2011, 11:19:01 AM »
Don't newer versions of AutoCAD keep system variables in the registry, including the ability to create your own with your own enumerated settings e.g. HKLM\Software\Autodesk\AutoCAD\XXXXX\xxxxx\Variables.  Should be able to query registry keys to pick them up, including application and user custom ones.

These are saved in the registry (doh). Except that others are saved in the registry under HKCU\...\Profiles\<ProfileName>\Variables. Then there are those that are saved in the drawing and those that aren't saved at all. Messy, isn't it?

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Get all AutoCAD system variables
« Reply #6 on: November 16, 2011, 01:15:51 AM »
Don't newer versions of AutoCAD keep system variables in the registry, including the ability to create your own with your own enumerated settings e.g. HKLM\Software\Autodesk\AutoCAD\XXXXX\xxxxx\Variables.  Should be able to query registry keys to pick them up, including application and user custom ones.
AutoCAD 2009 don't have it registry key... :(

From ADN I have received the answer that in.Net API it is impossible to make it. It can be made in ObjectARX only, through undocumented function of a C ++.
To write a manage wrapper for it it will not be possible, because as a result of its operation errors will be generated.:(
« Last Edit: November 16, 2011, 01:19:53 AM by Andrey »

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Get all AutoCAD system variables
« Reply #7 on: November 16, 2011, 12:30:18 PM »
Sorry you hit a wall with this.
If you wanted to take a brute force approach there is a nice listing of variables at http://www.hyperpics.com/system_variables/
You could create your own class and use Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("") to load it.
There are only 859 of them in 2011. :-o

If that class had a way to save and restore (import - export) a set of system variables that could be useful for CAD managers.

Don't forget to post your code in the "Reference Links for LIBRARY Routine threads" when you are finished.  :-D
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

kaefer

  • Guest
Re: Get all AutoCAD system variables
« Reply #8 on: November 17, 2011, 06:18:34 AM »
There are only 859 of them in 2011. :-o

Express Tools System Variable Editor dialog has 827 of them, in 2012. Their descriptions are plain text and in English.

Quote
If that class had a way to save and restore (import - export) a set of system variables that could be useful for CAD managers.

Would there be copyright issues if we check for Express Tools installation path and then snatch the keys to the descriptions mentioned above?

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Get all AutoCAD system variables
« Reply #9 on: November 17, 2011, 12:26:44 PM »
Sorry you hit a wall with this.
If you wanted to take a brute force approach there is a nice listing of variables at http://www.hyperpics.com/system_variables/
I want to receive all variables a program method instead of in the form of the table (then easier to look at them in help).
You could create your own class and use Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("") to load it.
I know it, but hoped that there is a method to receive that is necessary for me.