JavaScript Application Programming Interface (API) for AutoCAD
JavaScript Reference Guide

This guide documents the JavaScript Application Programming Interface (API) for AutoCAD�. 


Commands to load and execute JavaScript functions

Using the acedInvoke(�), you can call the JavaScript functions from your C++/.NET/LISP code. You can call the JavaScript functions by registering them using this global JavaScript function syntax: 

registerCallback(string name, callback) 

C++ API syntax and description
Acad::ErrorStatus acjsLoadJSScript(const ACHAR* uriOfHTML)

Loads an HTML file in a hidden window and executes the Javascript. This function is also exposed as WEBLOAD command in AutoCAD. 


Acad::ErrorStatus acjsDefun(const ACHAR* name, JsCallbackType callback);

Registers a callback that JavaScript code can call. 

Where JsCallbackType is defined as follows:

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

where JSON is defined as follows: 

JSON is a class/structure type that can represent JSON in C++. 


.NET API syntax and description

Assembly: accoremgd.dll 

Namespace: Autodesk.AutoCAD.ApplicationsServices.Core Class: Application 


void LoadJSScript(System.Uri  uriOfHTML)

Loads the HTML file specified and executes JavaScript code. 


If you want to call .NET function in JavaScript, you can define the function in .NET using this syntax:

  public string DotNetCallbackFunc(string json)


DotNetCallbackFunc is the user defined function. 


(webload, uriOfHtml )

Loads an HTML page and executes JavaScript code.

Copyright (c) 2016. All rights reserved.
What do you think about this topic? Send feedback!