WEBLOAD (Command)

Loads a JavaScript file from a URL, and then executes the JavaScript code contained in the file.

Prompts you to enter the name of a URL and JavaScript file. For example

Command: WEBLOAD
Enter name of URL to load: http://website/filename.js
Note: If you try to load a JavaScript file from an untrusted server, one that is not specified in the TRUSTEDDOMAINS system variable, a security warning will display.

The JavaScript file must contain a function definition and an invocation of the function as shown in the simple example below.

// Function definition
function pickPoint() {

    function onComplete(args) {

        var resObj = JSON.parse(args);
        if (resObj) 
            alert('You picked: ' + resObj.value.x + "," + resObj.value.y + "," + resObj.value.z);
    }

    function onError(args) {
        alert('Error picking point: ' + args);
    }

    var optionsFirst = new Acad.PromptPointOptions('Pick a point', new Acad.Point3d(0, 0, 0));
    Acad.Editor.getPoint(optionsFirst).then(onComplete, onError);
}

//Invocation of function
pickPoint();

Note: Any JavaScript function or AutoCAD JavaScript API function can be called. The one exception is the JavaScript prompt function, prompt(msg,defaultText).