SystemVariableEnumerator – new class in AutoCAD 2015

By Virupaksha Aithal

SystemVariableEnumerator class provides a way to iterate over all of the public system variables and get their names, data type, range (if applicable), read-only status, and how they are stored. In ObjectARX this call is represented by “AcEdSysVarIterator”

 

[CommandMethod("SysVarListTest")]
public void SysVarListTest() // This method can have any name
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;
 
    using(SystemVariableEnumerator sysVar 
                        = new SystemVariableEnumerator())
    {
        string storage = "";
 
        while (sysVar.MoveNext())
        {
            Variable var = sysVar.Current;
 
            switch (var.Storage)
            {
                case Variable.StorageType.PerDatabase:
                    storage = "PerDatabase";
                    break;
 
                case Variable.StorageType.PerProfile:
                    storage = "PerProfile";
                    break;
 
                case Variable.StorageType.PerSession:
                    storage = "PerSession";
                    break;
 
                case Variable.StorageType.PerUser:
                    storage = "PerUser";
                    break;
 
                case Variable.StorageType.PerViewport:
                    storage = "PerViewport";
                    break;
            }
 
            ed.WriteMessage(var.Name + "   " + storage + "n");
 
        }
    }
    //use Application.GetSystemVariable() to get the value.
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading