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.

3 comments:

I know this is "old school" at this point, but for some of us, its a comfort zone issue.Can someone explain why I cannot query the point number, its style, its label style?We are just starting on our Civil 3D journey and with all of the survey point styles and label styles, the users need to be able to quickly find some of these values. Most will need to control point display through layers. Since we are starting with a new layers standard, it will take time for them to get used to these and turning on and off point layers requires one to be able to quickly see the layers involved.BTW, I need to have this in 2009 and newer as we have projects in all versions.

I know this is "old school" at this point, but for some of us, its a comfort zone issue.Can someone explain why I cannot query the point number, its style, its label style?We are just starting on our Civil 3D journey and with all of the survey point styles and label styles, the users need to be able to quickly find some of these values. Most will need to control point display through layers. Since we are starting with a new layers standard, it will take time for them to get used to these and turning on and off point layers requires one to be able to quickly see the layers involved.BTW - This is need in 2009-2013 as we have projects in all versions.