Tutorials > 

To Set a System Variable Value

 
 
 

The AutoCAD JavaScript tutorial demonstrates how you can set a value for any system variable in AutoCAD using JavaScript.

  1. Use the following JavaScript code to set the value for the COORDS system variable to 1:
    var sysvarObject = Acad.SystemVariableCollection.getSystemVariable("coords");
    sysvarObject.value = 1;
  2. Save the file as SysVar.js.
  3. Register the domain from where you want to load the JavaScript file using the TRUSTEDDOMAINS sysvar.
    (setvar "TRUSTEDDOMAINS" (strcat 
    (getvar "TRUSTEDDOMAINS") ";mywesbite.com"))
  4. Use the WEBLOAD command in AutoCAD to load the SysVar.js file.
    (command "_.WEBLOAD" 
    "http://mywebsite.com/files/SysVar.js")
  5. From the AutoCAD command line, enter COORDS. The system variable value is set to 1.

    Setting COORDS system variable value using JavaScript