Now that we have released Civil 3D 2015, you might be wondering what is required to create a .NET addin project for this new release. First, let me point out that if you have a Civil 3D 2014 .NET addin, it should just work on 2015 in compatibility mode (.NET supports older versions).
Platform changes for Civil 3D 2015
There are some major changes you need to consider when creating a new addin. As mentioned, 2014 addins should work in compatibility mode. Here are the main points:
- Visual Studio 2012
- .NET 4.5
- 64 bit only – since 2014
- No Windows XP support
Configurable AutoCAD & Civil 3D
Now an interesting point: there is no Civil 3D 2015 install folder, it’s actually installed at the same folder as plain AutoCAD and there is a subfolder with Civil 3D specific files: [\Program Files\Autodesk\AutoCAD 2015\C3D]. Actually this change started back on 2014, see more details at this post.
This also means the Civil 3D will actually start AutoCAD with a few parameters. For instance, this is the default icon target for Metric profile: "C:\Program Files\Autodesk\AutoCAD 2015\acad.exe" /ld "C:\Program Files\Autodesk\AutoCAD 2015\\AecBase.dbx" /p "<<C3D_Metric>>" /product "C3D"
This change will affect our project settings… let’s see.
Required .NET references
First, as usual, we need to add reference to AutoCAD .NET references. Those are required as Civil 3D was build on top of AutoCAD. You may choose to download the ObjectARX SDK and get the references from [\ObjectARX 2015\inc] folder or simply get them from [\Program Files\Autodesk\AutoCAD 2015] folder. As Civil 3D 2015 is 64 bit only, there is no relevant difference between them. Here are the AutoCAD references required:
- AcMgd.dll – AutoCAD interface objects
- AcCoreMgd.dll – Core objects, used on both AutoCAD and Console
- AcDbMgd.dll – Database objects, required to access the drawing data
Now, Civil 3D will require its reference. As there is no SDK for Civil 3D, the reference is located [\Program Files\Autodesk\AutoCAD 2015\C3D] folder:
- AeccDbMgd.dll – Civil 3D main objects
When you start writing code, it will complain that another reference is missing. Actually our AEC products share some objects, therefore Civil 3D also needs reference to this common DLL located under AutoCAD [\Program Files\Autodesk\AutoCAD 2015] folder:
- AecBaseMgd.dll – AEC common objects, not directly used, but required
There are some other references, but those 5 are required, all others are optional and only used on specific features;
By default, Visual Studio will assume the references are required to run this code and then make a copy of the under the [\bin\] output folder of your .NET project. But, as this addin will load and run inside AutoCAD Civil 3D, the references are already there. So we need to specify the references as ‘Copy Local’ equals false. This is extremely important, otherwise Civil 3D will get confused and start crashing randomly.
Finally it’s time to build, but you’ll see a warning saying: “there was a mismatch between the processor architecture of the project being built”. This is somehow expected as the AutoCAD and Civil 3D references are 64 bit and the .NET project is Any CPU. You can simply ignore this warning or go to project settings and change the ‘Platform target’ to ‘x64’ (64 bit).
Setting up Debug options
Now we’re ready to debug the project. As Civil 3D is running as a configurable AutoCAD, you need to specify a few command line arguments. Actually, the same used on the icon. Below is a sample assuming the default install folder with Metric profile.
That’s it! You should be able to start developing for AutoCAD Civil 3D 2015 with these settings. Next topic, let’s talk about Interop settings.