Jump to content
btraemoore

simple simple... connecting to 2006 via interop

Recommended Posts

btraemoore

okay, im trying to get a connection to 2006 and im having problems. i used keen(through the interface) example and its throwing a COM exception, BUT it is creating the instance of autocad. I dont think it is connected to it, but it creates it.

 

NOW, when i downloaded the objectARX for 2006 there where no interop.dll's just the 3 "acdbmgd" variations... im just learing how to work with c#. Can some one throw me a little bone here :) here is my code.

 


public MainForm() {
		InitializeComponent();
		IMessageFilter oldFilter = default(IMessageFilter);
		CoRegisterMessageFilter(this, oldFilter);
		
		AcadApplication acApp = GetAcApp("AutoCAD.Application.16.2");
		
	}
	
	public AcadApplication GetAcApp(string progID){
	AcadApplication acApp = null;
	try {
		acApp = (AcadApplication)Marshal.GetActiveObject(progID);
	} catch {
		try {
			Type acType = Type.GetTypeFromProgID(progID);
			acApp = (AcadApplication)Activator.CreateInstance(acType,true);
	
		} catch {
			MessageBox.Show("Cannot create object of type \"" + progID + "\"");
		}
	}
	if (acApp != null) {
		// By the time this is reached AutoCAD is fully
		// functional and can be interacted with through code
		acApp.Visible = true;
		return acApp;
	}
	return null;
}

Share this post


Link to post
Share on other sites
BlackBox

It sounds like you're attempting to create a stand-alone EXE, in lieu of a plug-in (an assembly that is loaded into an active session of AutoCAD), is this correct?

 

If instead you're after a plug-in, and you're already coding in C#, why not just use the .NET API (AcDbMgd.dll, AcMgd.dll) in lieu of COM?

Share this post


Link to post
Share on other sites
btraemoore

I would like to learn both using the .NET API and COM. I have had a really hard time finding some good examples that explain verbosely about both. If you know where i can find any i would be very appreciative.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×