Jump to content

simple simple... connecting to 2006 via interop


btraemoore

Recommended Posts

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;
}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...