Could you describe the situation in detail? Such as what is your "own app" and where it runs...?
If you mean an EXE application that you want to use to automate AutoCAD via COM, then yes, besides existing AutoCAD COM model, you can expose your AutoCAD .NET addin object (NETLOADed into AutoCAD) as COM and access it from outside AutoCAD. However, this way you need to register the exposed COM in registry, which is a hussle work to do.
You can also use WCF to communicate AutoCAD. That is hosting an WCF service inside AutoCAD add-in, and call the service from outside EXE app.
However, since AutoCAD is very complicated desktop application, it is really designed for user to control it, not for being used as non-user interactive server. It is better to do the automation the other way around. If you are looking for doing some kind of batch processing work with AutoCAD, you may look into AutoCAD console app (since AutoCAD 2013). Or if the batch process only involves drawing data retrieving/update, you may look into license RealDwg. When automating AutoCAD for a batch process, sometimes user interence is inevitable/required.
Norman Yuan
Hi cccberlin,
AutoCAD has a comprehensive COM (ActiveX) API that can easily be used to automate it from an external application. Please explain what specific problems/errors are you seeing that make you say "AutoCad don't want to talk with us", and then someone may be able to tell you what you're doing wrong.
Ok - so you're having trouble finding documentation for the ActiveX API. Go to http://www.autodesk.com/developautocad and then scroll down the page until you get to the ActiveX API link in the Documentation section. That will tell you where to find it.
Also, if you're using COM automation of AutoCAD 2010 or higher from an external .NET application, then this blog post will help you - http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-b... . You shouldn't have to worry if you're doing it from VBA in Excel or similar.
Also, you may have more success asking ActiveX API questions on the AutoCAD->Visual Basic Customization forum.
You can expose a .NET class in an AutoCAD managed extension to external COM clients and access it via the GetInterfaceObject() method of the AutoCAD Application Object, by passing it the ProgId of your COM class. For that to work, you need to derive your COM class from System.EnterpriseServices.ServicedComponent (I also recommend reading up on it first).
With the COM class registered correctly, you shold only need to get the AcadApplication COM object, and call its GetInterfaceObject() method, and that should create an instance of your COM class and return it to the consumer.
I just noticed, that I didn't mention some important details: I use C# and ACad & Inventor are version 2013.
Despite COM is almost outdated I'll try it first:
AcadDocument doc = acadapp.ActiveDocument;
foreach (object myobject in doc.ModelSpace) { AcadDimension dim = myobject as AcadDimension; if (dim != null) { //to avoid casting every type of dimension ... //because many properties are available by their corresponding interface only, even they are identical dynamic dyndim = dim; object oxdatatype = new object(); object oxdatavalue = new object(); dim.GetXData("", out oxdatatype, out oxdatavalue); short[] xdatatype = oxdatatype as short[]; object[] xdatavalue = oxdatavalue as object[]; } }
This works, but isn't really pretty, isn't it?
After casting "dim" it is still a ComObject ...
Regards,
Chris