To Load and Execute JavaScript APIs

 
 
 

Use the WEBLOAD command in AutoCAD, acjsLoadJSScript() in C++, Application.LoadJSScript() in .NET, or webload in LISP to load and execute JavaScript code.

Using the acedInvoke(…), you can call the JavaScript functions from your C++ code. Register the functions using a global JavaScript function, the syntax is:

defun(string name,callback)

Using C++ API

  1. Execute the javascript functions using this API:
    Acad::ErrorStatus acjsLoadJSScript(const ACHAR* uriOfHTML)
  2. Register a callback for the JavaScript using:
    Acad::ErrorStatus acjsDefun(const ACHAR* name, 
    JsCallbackType callback);

    where jsCallbackType is defined as:

    typedef  JSON (*JsCallbackType)(const JSON* params)

Using .NET API

Use this information to load the .NET assembly, you would require for executing the JavaScript APIs:

.NET Assembly Information

Assembly accoremgd.dll
Namespace Autodesk.AutoCAD.ApplicationsServices.Core
Class Application

  1. Execute the javascript functions using this API:
    void LoadJSScript(System.Uri  uriOfHTML)
  2. Register a callback for the JavaScript using:
    void DefunJS(String name, JsCallbackType callback)

    where jsCallbackType is defined as:

    typedef  JSON (*JsCallbackType)(const JSON* params)

Using LISP API

Execute the javascript functions using this API:

(command “._webload” uriOfHtml)