AutoCAD Civil 3D Customization

Reply
Distinguished Contributor
jmaeding
Posts: 932
Registered: ‎12-27-2006
Message 1 of 5 (192 Views)
Accepted Solution

new AeccApplicationClass does not work in .net 2013?

192 Views, 4 Replies
01-30-2013 03:43 PM

I have code from the past that gets an AeccApplicationClass using:

// Note: GetInterfaceObject() has a bug in it.  It uses the default Windows object marshaller,
// which can result in it returning the AeccApplication from the wrong instance of Autocad if more
// than one instance is running.  This creates a problem even if the other instance is another
// Autocad product, such as Land Desktop.  So instead of using GetInterfaceObject(), we instead
// use this method to get the AeccApplication.
public IAeccApplication CivilApp {
	get {
		if (_civilApp == null) {
			_civilApp = new AeccApplicationClass();
			_civilApp.Init((IAcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication);
		}
		return _civilApp;
	}
}

 

 

 I got this from one of the gurus, not taking credit for it by any means.

When I do the reference changes suggested in

 http://adndevblog.typepad.com/infrastructure/2012/04/com-references-on-civil-3d-2013.html

and

http://blog.civil3dreminders.com/2012/04/upgrading-to-civil-3d-2013-programming.html

I get errors on the "new AeccApplicationClass();" line, VS 2010 says "...cannot be embedded, use applicable interface instead...".

 

This code might be from the free SincPac, to which i know there are several fans out there.

Any ideas what the proper way is now to make the AeccApplicationClass object?

thanks

 

*Expert Elite*
Jeff_M
Posts: 4,178
Registered: ‎07-22-2003
Message 2 of 5 (192 Views)

Re: new AeccApplicationClass does not work in .net 2013?

01-30-2013 04:39 PM in reply to: jmaeding

This is what we did, where we have the conditional compilation symbol of C3D2013:

               if (aeccApp == null)
                {
#if !C3D2013
                    aeccApp = new AeccApplicationClass();
#else
                    aeccApp = new AeccApplication();
#endif     
aeccApp.Init((AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication); }

 

Jeff_M, also a frequent Swamper
Distinguished Contributor
jmaeding
Posts: 932
Registered: ‎12-27-2006
Message 3 of 5 (179 Views)

Re: new AeccApplicationClass does not work in .net 2013?

01-30-2013 08:36 PM in reply to: Jeff_M

what would I do without you Jeff?

I hate to mooch off others skills too, these api changes are rather hidden though.

Distinguished Contributor
jmaeding
Posts: 932
Registered: ‎12-27-2006
Message 4 of 5 (168 Views)

Re: new AeccApplicationClass does not work in .net 2013?

02-01-2013 09:48 AM in reply to: Jeff_M

That worked great.

The way I handle different code needed for different acad versions is by making separate projects for each version.

So I have several "helper" libraries added to my solution:

C3D R19 Tools

Acad R19 Tools

 

In those helper projects, there are several code files, like this:

Utils.cs

Utils R19.cs

 

The Utils.cs has a class called "C3DUtil". I define it as a partial class, then also have a partial class in the Utils R19.cs which has the version specific code.

 

The end result is each program I produce has a solution for each version of acad (ouch).

Also, each helper library has a different project for each version, to allow combinations of partial classes.

 

I post this because I wish there were better ways of doing things. Conditional compilation symols do allow some simplification, but I need control of references too. Curious to hear if that can bve dealt with any other way than multiple projects/solutions.

*Expert Elite*
Jeff_M
Posts: 4,178
Registered: ‎07-22-2003
Message 5 of 5 (164 Views)

Re: new AeccApplicationClass does not work in .net 2013?

02-01-2013 10:38 AM in reply to: jmaeding

I do pretty much the same thing with the Projects, 1 for each version of C3D...and with 2013 it's worse because if you use the COM Interops you must build one for each of the x86 & x64 versions of C3D. But rather than have separate code files, we use the Symbols exclusively...but that can turn into it's own mess, too.

 

Now, if you convert the code to use all .NET API where possible and access the COM via late-binding, then only one is needed for 2013 (and the same dll may work for the next version as well, can't wait to test that theory). This is something I've been working on doing in my spare time, and I have it about 95% complete. There is some old code which I wrote in probably the wrong way which is now proving difficult, at best, to move away from the Interops. But as long as I leave these 3 commands out, my COM free project is working quite well in both x86 & x64 C3D2013.

Jeff_M, also a frequent Swamper

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs