Advertise with us
3D Plugin

Displaying a Graph of AutoCAD Drawing Objects Using JavaScript and .NET

3d Model

Kean Walmsley, the author, worked on the Displaying a graph of AutoCAD drawing objects using JavaScript and .NET

It seems like the author has been living in JavaScript land (and no, he deliberately did not say “hell” – it’s actually been fun :-) for the last few weeks, between one thing or another. But I think I’ve finally put the finishing touches on the last of the JavaScript API samples he have prepared for http://au.autodesk.com/

Jim Awe – an oldtime friend and colleague – who is working on something similar for another platform samply, inspired this. Therefore, the author cannot take any credit for the way it works, just for the plumbing it took to make it work with AutoCAD.

It is overall an HTML palette using a handy open source library called http://d3js.org/ for Data-Driven Documents – and http://d3pie.org/ a layer on top of that to simplify creating pie charts. The palette connects to the active drawing and asks to .NET to provide some data on the entities inside modelspace. From our .NET code we use LINQ to query the types of object from the modelspace’s ObjectIds, which we then package up as JSON and go back for display in HTML.

This is all that has needed to get this data, in case – it can all be done via the ObjectId without opening any of the entities (just the modelspace). LINQ is great at this kind of query.

AutoCAD Drawing Objects