Copying a surface with Civil3D, a better way?
January 30th, 2008
Reading Pete Kelsey’s post “Copying a Surface with Civil3D” I was amazed at his seven step response. My first thought was couldn’t you right-click on a surface in the prospector and select COPY. So I opened up a drawing in C3D, went to the prospector, right clicked and to my surprise, no copy command.
I am a C3D fan, but I am amazed at basic everyday functionality left out of the software. I know C3D is a new platform and not a Land Desktop clone. However, our work flow has been built around Land Desktop functionality. The right click copy surface has been with us in the LD terrain model explorer for years. Copying a surface is a typical if not daily task in 3D site modeling. Using the vanilla autocad copy command with seven steps is unacceptable. So I started looking for a ‘better way’.
We didn’t have to look too far. the API provides a copy method for the surface object. Writing the code to copy the surface would be easy. Adding the right-click functionality to the prospector isn’t as simple. We can easily add right-click functionality to the surface object in model space. The user would simply select the surface then right click and select ‘copy surface’.
Keep in mind setting this customization up does take more than 7 steps, but once it is implemented it is a nice feature.
This builds on my previous post adding right-click functionality to C3D objects. Another big thanks to David for making these available. If you haven’t downloaded and installed his custom cui, do it now. You will now have the right click functionality for C3D objects.
Open your cui by typing cui at the command prompt.
Once in the cui expand the Shortcut Menus, then expand the AECC_TIN_SURFACE shortcut menu.

Now right click on Check for Contour Problems and select add separator. As shown above.

The next step is to define the copy surface command. Click the create new command button as shown above.

Add the following name Copy Surface and command ^C^Ccs; as shown above.

Now apply and close your cui. Open a dwg with a surface. Right click on the surface, you’ll see your new right click command as shown above. We’re halfway there.
Next step is to define our command. If you aren’t interested in the details you can skip to the bottom and download the zip file.
Here’s the basic VBA code needed.
Dim AecSurface As AeccTinSurface
Dim AecSurfaceNew As AeccTinSurface
Set AecSurface = ThisDrawing.ActiveSelectionSet.Item(0)
Set AecSurfaceNew = AecSurface.Copy
Four simple lines and we’ve copies the selected surface.
The complete VBA dvb file is included in the zip file below. Code has been added to handle renaming the surface.
The last step is to create a LISP routine to call the VBA. Below is the routine, it is included in the zip file below.
(defun c:cs ()
(vl-vbarun “C:/civil3dblog.com/vba/copysurface.dvb!cs”)
(princ)
)
Download the zip file of the routines here. Save the zip file to your c:/ and right click and select extract all. It should place the files in the proper folders.
Then appload the cs.lsp located in the /lisp folder into your drawing, also add it to your startup suite so it is available in all your drawings.
Now right-click on a surface and select copy surface, your surface is duplicated. Check out the prospector.
This will give you a good starting point for adding other missing functionality to Civil 3D.
If you have any questions or feel additional information should be posted leave a comment and we will update the post.



