c# and Preferences
Hello i'm new to BricsCAD developement and wanted to start with some basic stuff.
So i tried to programmatically change some values like the template path but i can't get the preferences object from the Brics-application.
How can I get this done in C#?
Comments
-
Hi, Most of these settings are available through Application.GetSystemVariable, example.
[code] [CommandMethod("doit")] static public void doit() { AcAp.Document doc = AcAp.Application.DocumentManager.MdiActiveDocument; try { string env = AcAp.Application.GetSystemVariable("TemplatePath") as string; doc.Editor.WriteMessage(env); AcAp.Application.SetSystemVariable("TemplatePath", your path); } catch (System.Exception ex) { AcAp.Application.ShowAlertDialog( string.Format("\nError: {0}\nStackTrace: {1}", ex.Message, ex.StackTrace)); } }[/code]Cheers : )
0 -
[code]
[CommandMethod("doit")]
[/code]
static public void doit()
{
AcAp.Document doc = AcAp.Application.DocumentManager.MdiActiveDocument;
try
{
string env = AcAp.Application.GetSystemVariable("TemplatePath") as string;
doc.Editor.WriteMessage(env);
AcAp.Application.SetSystemVariable("TemplatePath", your path);
}
catch (System.Exception ex)
{
AcAp.Application.ShowAlertDialog(
string.Format("\nError: {0}\nStackTrace: {1}", ex.Message, ex.StackTrace));
}
}0 -
sorry for the formatting : |
Also, these might be handy as they wrap acedGetEnv and acedSetEnv
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("Brx13.DLL", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl)]
internal static extern int acedGetEnv(string envName, StringBuilder ReturnValue);[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("Brx13.DLL", CharSet = CharSet.Auto,
CallingConvention = CallingConvention.Cdecl)]
internal static extern int acedSetEnv(string envName, StringBuilder NewValue);public static string GetEnv(string envName)
{
StringBuilder buf = new StringBuilder(2048);
acedGetEnv(envName, buf);
return buf.ToString();
}public static bool SetEnv(string envName, string newValue)
{
StringBuilder buf = new StringBuilder(newValue);
return acedSetEnv(envName, buf) == 5100;
}0