Looks like you got it Keith but updating code for 2015 and thought I would through some different ways to modify PreferenceFiles.
Here is one way and as is requires .NET 4.5 but could be modified for earlier versions.
It uses the name of the properties for the variable name with
CallerMemberNameAttribute , and just add a property for each and make sure property names match environment variable names.
[CommandMethod("EnviroTest1")]
public void EnviroTest1()
{
Ed.WriteLine(EnviromentVariables.QnewTemplate);
}
[CommandMethod("EnviroTest2")]
public void EnviroTest2()
{
EnviromentVariables.QnewTemplate = @"J:\CadManaged\AutoCAD\Hgce\Templates\HgceBase.dwt";
Ed.WriteLine(EnviromentVariables.QnewTemplate);
}
public static class EnviromentVariables
{
[DllImport("accore.dll", CallingConvention = CallingConvention.Cdecl,
CharSet = CharSet.Auto, EntryPoint = "acedSetEnv")]
extern static private Int32 acedSetEnv(string var, string val);
private static string GetEnviromentVariable([CallerMemberName] string name = "")
{
return HostApplicationServices.Current.GetEnvironmentVariable(name);
}
private static void SetEnviromentVariable(string value, [CallerMemberName] string name = "")
{
acedSetEnv(name, value);
}
public static string ACAD
{
get { return GetEnviromentVariable(); }
set { SetEnviromentVariable(value); }
}
public static string QnewTemplate
{
get { return GetEnviromentVariable(); }
set { SetEnviromentVariable(value); }
}
}