Share

To Set a System Variable Value

This AutoCAD JavaScript tutorial demonstrates how to set the value of a system variable.

In this tutorial you will,

  • Get a system variable from the SystemVariable Collection with the getSystemVariable function

  • Change the value of the COORDS system variable to 1

    1. Type the following JavaScript statements in a plain text file.

      Acad.SystemVariableCollection.getSystemVariable("COORDS").then(function(arg){arg.set_value(1);},function(){alert("set failed!")});
    2. Save the file as SysVar.js.

    3. At the AutoCAD command prompt, enter coords and set the new value to 0.

    4. At the AutoCAD Command prompt, enter webload and then press enter again to use the Load option.

    5. At the Enter javascript URL to load: prompt, enter the URI to the SysVar.js file.

      http://mywebsite.com/files/SysVar.js

      The file can also be in a local directory which in that case the URI might look like:

      c:\files\SysVar.js
      file:///c:/files/SysVar.js
    6. At the AutoCAD command prompt, enter coords. Press Enter after you verified the value has changed.

      The system variable value should now be set to 1.

      Setting COORDS system variable value using JavaScript image

Was this information helpful?