Objectarx for autocad 2014
Obviously, when AutoCAD is receiving request from Http and working in the request, the AutoCAD session should not be operated by a user, as least when the hosted Http server is working on a request.
That is good enough to lock the document and perform some operation against WorkingDatabase.
OBJECTARX FOR AUTOCAD 2014 CODE
As the code showed, HostApplicationServices.WorkingDatabase is reachable and a Document can be obtained via the database. Yeah, I was afraid that the Http server may have difficult to call into AutoCAD operation when I started, but went ahead for a try anyway. This video clip shows using Fiddler to have AutoCAD draw a circle.Īfter verifying the Web API server hosted in AutoCAD works as expected with Fiddler, I then continued the exploration to start the third project, a WinForm application with its UI looks like: This video clip shows using Fiddler to get/set AutoCAD system variable. I used Fiddler for testing the above self-host Web API code in AutoCAD before I actually wrote a Http client application.
OBJECTARX FOR AUTOCAD 2014 FREE
Now with just the 2 projects (AcadHttpDto and AcadHttpServerHost) being built, AutoCAD is ready to host the Http Web API inside and accept external requests and acts accordingly.įor any programmer who is familiar to web programming, Fiddler is a very well-known, a must-have free tool. If I want to drawing something else rather than circle, I would create another Dto data class in AcadHttpDto project (say, LineArgs, which has data for a line's 2 end points) and add an overloaded Put() method that has different argument (LineArgs for drawing a line). I did not bother, or have time, to dig out the reason, as long as my exploration worked the way I did it.Īlso, by following Http command tradition, the Put() method is meant for updating, thus the DrawController uses Put() to take client's request to draw something in AutoCAD. If looking into the code carefully, one would notice that I get a reference to current drawing document via HostApplicationServices.WorkingDatabase->(Database)ĭue to the way the Http self-host server runs, the MdiActiveDocuement is not available. The Visual Studio solution and 3 projects in the solution are shown in pictures below: NET 4.0 is because the NuGet Manager only allows to get latest ASP.NET Web API Self-Host package, which requires. I used Visual Studio 2012/.NET 4.5 and AutoCAD 2014. It only shows a new way how AutoCAD can be automated from external application. So, the code I show here may not have much practical value to my real word AutoCAD development. To be honest, I am not a fan of automating AutoCAD from external application, even though I did develop a few applications doing this (mostly some kind of drawing batch processing operations), because AutoCAD is a very complicated desktop application and it is very often that an AutoCAD process needs user interaction to complete. So, I explored a bit to see how I could use this technology to automate AutoCAD. Its communication conduit is purely based on Http protocol, which, besides can be hosted in Windows' IIS server, can also be self hosted easily, thus effectively make its host's computing power available to outside world. Like WCF, it is regarding communication between processes/applications, a much simplified in comparison to WCF. In spite its name "ASP.NET Web API" say "ASP.NET" and "Web", Web API is not just for web application. For those who want to know more about ASP.NET Web API, go to here for more details. I recently worked on a web application development project, in which ASP.NET Web API is used to expose business data as OData to be consumed by user side application (web application, mobile application or desktop).
There are a few samples/articles/post on this topic can be found on the Internet (unfortunately I did not keep their links:-(). NET communication mechanism between processes/applications can be used to automate AutoCAD. However, there are still times when people want to automate AutoCAD from external process/application, in which AutoCAD COM API still has significant advantage due to its fairly complete COM object model.ĪutoCAD can also be automated from external application in pure. NET API won most, if not all, AutoCAD programmers' favorite and AutoCAD COM API has been gradually fade into background. NET API, we used AutoCAD's COM API for both in-process (VBA or DLL that loads into VBA) and out-process (EXE) automation of AutoCAD. Then AutoCAD.