This post will go through the steps to get point information from a point and send the information to the command line.
The first thing we want to do is to make sure Civil 3D is running. To do this open the SurfacePoints example that comes with Civil 3D and export the Base Objects code. The sample code is located at:
C:\Program Files (x86)\AutoCAD Civil 3D 2009\Sample\Civil 3D API\Vba\SurfacePoints
Next go create a new VBA project through the VBAMAN command and then import the module into the new file.
Now go insert a new module into the ACADProject.
Next make sure the Land references are included, from the Menu: Tools > References
Now add Option Explicit at the top of the newly created module and Sub PointInfo(), the End Sub should automatically be created. The Option Explicit requires you to use DIM all of the variables used in the code, otherwise VBA assumes that value and that may cause problems if you want a specific type of object.
Now go into the subroutines module of the SurfacePointsSample and copy the lines that check to see if Civil 3D is running and gets the Civil 3D application and document.
Now paste it into the PointInfo() sub. This will make sure Civil 3D is running, if it's not the sub will be ended and an error message will be given to the user.
Now that we've done the housekeeping we can start to write the code to get a point using the ThisDrawing.Utility.GetEntity.
The AcadEntity is just a generic AutoCad entity and the vPoint is a variant. A variant is kind of like a junk entity, it will store almost anything, in this case it stores three number values representing the location the user selected. So now that we hopefully have the point from the user we need to make sure the user selected the point using the If/Then and TypeOf to make sure the user selected a point.
If it is we create a variable for an Aeccpoint and set it equal to the oAcadObj. We'll also add an Else to tell the user what he did wrong.
So now have the point we'll send the point information to the command line using the prompt Method of the Utility object.
So that's almost it. Just add some error catching, maybe an "On Error Resume Next" at the top or an "On Error Resume Next" above the GetEntity line and an "On Error Go to 0" to turn it off in case the user doesn't select an object and around the Description line if the point doesn't have a description assigned which will also cause an error.
The completed VBA may be found on this page: http://style.civil3dreminders.com/programming