New Member
2 Posts
0 Kudos
Registered: ‎09-26-2013
Post 1 of 3

How to get the Object Properties by Javascript

246 Views, 2 Replies
09-26-2013 04:30 AM

How to get the Object Properties by Javascript

Hello :smileyhappy:

I just started to learn javascript programming for AutoCad.

I found that it is hard for me to get the property of selected object by Javascript.

Just like the following code, I can get the object ID of each selected entity. But when I want to get the property of the DBEntity, just the center of a Circle entity, or the Position.X of a Point, I dont know how to Continue. The getExtent is the only function that I can writeout the property, it is List in the develop guide. But how about the other properties, could you please help me? Thank you very much.



function setPromptSelectionOptions(options) {
options.messageForAdding = "\n Please select some entities"
function onCompletePromptSelectionResult(jsonPromptResult) {
var resObj = JSON.parse(jsonPromptResult);
if (resObj) {
if (resObj.status == 5100) { // normal (point selected/entered)
var x=JSON.stringify(resObj);
var allselect=resObj.value
var i=0;
for (var x in allselect)
var z=allselect[i];
var entity = new Acad.DBEntity(z.objectId);
// var ext = entity.getExtents();
function onErrorPromptResult(jsonPromptResult) {
function promptForSelectionqjchen() {
var options = new Acad.PromptSelectionOptions();

Acad.Editor.addCommand( "Q_CMDS", "ABC", "ABC",Acad.CommandFlag.TRANSPARENT, promptForSelectionqjchen );
write("\nRegistered abc command.\n");

ADN Support Specialist
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 3

Re: How to get the Object Properties by Javascript

09-27-2013 05:13 AM in reply to: qjchen



There is no way to achieve that directly from the JavaScript API. it is only the first version, so this API is not very powerful.


You can find the API Reference here.


We also produced material about it. One solution might be to use either an arx or .Net extension and pass the objectId from JavaScript to your arx/.Net method in order to retrieve the properties you are looking and return that to JavaScript.


Extending the JavaScript API from arx/.Net is discussed in my DevTV.


Another useful link:






Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

New Member
2 Posts
0 Kudos
Registered: ‎09-26-2013
Post 3 of 3

Re: How to get the Object Properties by Javascript

09-27-2013 04:49 PM in reply to: philippe.leefsma

Hi, Philippe


Thank you very much for your reply. Therefore I won't stick to solve it in pure JavaScirpt. I will try to use .Net to complement the getting and drawing entity for Javascript API.

Just like Kean published here

Surely I hope this will be included in the subsequent Autocad Javascript API version.

Your article and its attachment in "Getting Started with JavaScript API on AutoCAD 2014" is the most important material for me to get into JAVASCRIPT programming on AUTOCAD. I test all the examples in AcHTML and learn a lot. Certainly, I am also learing the useful examples shared by kean.

What I think that the funny things JAVASCRIPT giving us, have several aspects, such as Interface programming (html), easy to using bundles of libraries of JAVASCRIPT in internet like D3 or Raphaël or else, publishing the source codes online.


I have just wrote several Javascript codes, just like using tree menu to manage my customized command, using D3.js to draw delaunay figure, etc. It give me a different feeling than Lisp and .Net and I enjoy it.

Thanks again.

Best Regards.


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!