Visual Studio .NET settings for Civil 3D 2015

By Augusto Goncalves

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:

  1. AcMgd.dll – AutoCAD interface objects
  2. AcCoreMgd.dll – Core objects, used on both AutoCAD and Console
  3. 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:

  1. 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:

  1. 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;

copylocal_falseBy 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.

debug_VS

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.


Comments

8 responses to “Visual Studio .NET settings for Civil 3D 2015”

  1. Thanks Augusto.
    Very helpful post. One thing I noticed with 2014 code in 2015 is that even though the code runs, dialog boxes seem to shrink a bit and don’t appear as they do in 2014. I’ll ultimately be upgrading my apps to VS 2012 specifically for 2015 anyway, but I am curious. Any ideas as to why?

  2. Steve,
    I’m not aware of any issue. Also, tried on my end (same DLL on both version) and the Forms are exactly the same (size, style, etc).
    If you have a repro sample, please send to me, will investigate.
    Regards,
    Augusto Goncalves

  3. Hi
    I’m going with the programming language C # in Visual Studio AutoCAD software developed.plz help me.

  4. Saman,
    These VS settings are independent of language, you need to configure for both VB.NET and C#. If you have a specific question, please use our forum: http://forums.autodesk.com/t5/autocad-civil-3d-customization/bd-p/190
    Regards,
    Augusto Goncalves

  5. Borja1980 Avatar
    Borja1980

    Hi. I have done the steps described here, and the proyect compiles perfectly. However, when i start debuging, acad.exe starts executing, and allways crashes. I hace reinstalled visual studio 2012 and civil2015, but the problem persist. I would like to know i somebody has run into a similar problem, and has been able to finde a solution.
    Thanks

  6. Hi,
    I would need more details on what’s happening (error message).
    You can also try with the template at http://adndevblog.typepad.com/infrastructure/2014/09/civil-3d-project-template-for-visual-studio.html
    Regards,
    Augusto Goncalves

  7. hellow
    i want create programing for optimazation vertical and horizontal alignment, do you have any sugestion for me.

  8. Hi, this could give you a starting point: http://adndevblog.typepad.com/infrastructure/2012/08/replacing-alignment-entities.html
    Regards,
    Augusto Goncalves

Leave a Reply