How to access the AutoCAD Civil 3D Survey Database in .NET Application?

By Partha Sarkar

In AutoCAD Civil 3D COM API, using AeccSurveyDatabase:: Projects, we can access the collection of the existing Survey projects. If you want to access a particular Survey Project e.g. (Test_Survey_DB) as shown in the screenshot below, we can use the AeccSurveyProjects:: FindItem(VARIANT varIndex).

 

Civil3D_Survey_Database

 

Here is a C# .NET code snippet which demonstrates how to access a particular Survey Project using the COM API  : 

// Get the AutoCAD Editor
Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
 
// Get the Survey Application and AeccSurveyDatabase
AeccSurveyApplication aeccSurveyApp = newAeccSurveyApplication();
aeccSurveyApp.Init((AcadApplication)AcadApp.AcadApplication);
AeccSurveyDatabase aeccSurveydb = (AeccSurveyDatabase)aeccSurveyApp.ActiveDocument.Database;
AeccSurveyProjects surveyProjs = aeccSurveydb.Projects;
 
// Accessing a Particular Survey Project
// IAeccSurveyProjects:: FindItem 
// Gets the Survey Project with the given name. 
 
AeccSurveyProject surveyProj = surveyProjs.FindItem("Test_Survey_DB");
if (surveyProj != null)
{
  // now we can access the various Props of AeccSurveyProject object            
  ed.WriteMessage("nSurvey Project Name :  " + surveyProj.Name.ToString());
  ed.WriteMessage("nSurvey Project Path :  " + surveyProj.Path.ToString());
  ed.WriteMessage("nNext available point number   : " + surveyProj.GetNextWritablePointNumber().ToString());
}

Comments

3 responses to “How to access the AutoCAD Civil 3D Survey Database in .NET Application?”

  1. When I try this example (using 2013, and VB .Net), I am unable to load the AeccXSurvey and AeccXUiSurvey type libraries. Am I added the correct references?

  2. Hi Dave –
    For Civil 3D 2013 COM libs, please refer to the following topic –
    http://adndevblog.typepad.com/infrastructure/2012/04/com-references-on-civil-3d-2013.html
    Thanks,
    Partha

  3. Thanks, that was very useful!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading