A pair of functions, acedGetVar() and acedSetVar(), enable ObjectARX applications to inspect and change the value of AutoCAD system variables. These functions use a string to specify the variable name (in either uppercase or lowercase), and a (single) result buffer for the type and value of the variable. A result buffer is required in this case because the AutoCAD system variables come in a variety of types: integers, real values, strings, 2D points, and 3D points.
The following sample code fragment ensures that subsequent FILLET commands use a radius of at least 1.
struct resbuf rb, rb1; acedGetVar("FILLETRAD", &rb); rb1.restype = RTREAL; rb1.resval.rreal = 1.0; if (rb.resval.rreal < 1.0) if (acedSetVar("FILLETRAD", &rb1) != RTNORM) return BAD; // Setvar failed.
In this example, the result buffer is allocated as an automatic variable when it is declared in the application. The application does not have to explicitly manage the buffer's memory use as it does with dynamically allocated buffers.
If the AutoCAD system variable is a string type, acedGetVar() allocates space for the string. The application is responsible for freeing this space. You can do this by calling the standard C library function free(), as shown in the following example:
acedGetVar("TEXTSTYLE", &rb); if (rb.resval.rstring != NULL) // Release memory acquired for string: free(rb.resval.rstring);