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
functionChange the value of the COORDS system variable to 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!")});
Save the file as SysVar.js.
At the AutoCAD command prompt, enter coords and set the new value to 0.
At the AutoCAD Command prompt, enter webload and then press enter again to use the Load option.
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
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.