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
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
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); }
what would I do without you Jeff?
I hate to mooch off others skills too, these api changes are rather hidden though.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
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.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties
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.