Sunday, June 10, 2012

Civil 3D Find and Replace

Have you have had to rename a lot of different objects in Civil 3D? Or even have to change the descriptions?

For instance if you grade in a channel, you might make an alignment called Channel 5, which will also have a profile called Channel 5, which is on a profile view called Channel 5, which has an assembly called Channel 5, which all makes up a corridor called Channel 5, which has a corridor surface called Channel 5, which is pasted in a surface with a name reference to Channel 5. Then the engineer decides to renumber the channels... now your channel is Channel 100. Oh and there are about 15 different channels like this in your drawing. Good luck making sure everything reads as it should for the next person who uses the file.

This drove me to write a new command... C3D Find and Replace. I mean we can do a find and replace on regular text, why not on names and descriptions of objects???

Here are a few screenshots and a video showing the command in action.















You can watch the command in action here.



Thursday, June 7, 2012

Copy Surface Profile and Perform Raise/Lower Command

For those of you who read my posts, you probably have realized that I am all about less clicks and less menus. Civil3D can get somewhat confusing with the hidden operations to perform specific tasks. One of those very tasks that is somewhat hidden is the copy profile from surface procedure. There are a number of dialogs that you must go through and change a setting from static to dynamic, then get into the profile geometry editor, make a copy of the profile, go back and change the original profile's setting back to dynamic. You can find more detailed explanation of how to do this here and here.

In order to save more clicks and to speed up the process, I automated it programmatically. In this first image, the code begins with prompting for a selection of a profile. The 'prmpt.AddAllowedClass' line tells the software what type of object we are looking for. Anything other than a profile will return the reject message listed above. Next, this command was built for copying surface profiles, thus we perform an if/then statement on the selected profile type to verify the type is EG type. Note that the EG type stands for existing ground, though the user could create a profile on a proposed surface, and that would perform the same way.

Next we prompt for a raise or lower value. Upon copying, the command will adjust the PVI values automatically. This command also places a corresponding name and description on the profile, thus you'll see the if then statement checking the value of the typed in distance. If it's negative, it will display LOWERED, if it's positive it will display RAISED.

See the first image below.




The second image we arrive at the TRY statement, we have to gather information about the selected profile. So we store data about the profile in 'alignment', 'layerId', 'surfaceId', styleId' and 'labelSetId'. Note that these are all the items a profile requires to create from a surface. After gathering the previous profile information, I set the new profile name and the new profile description. I have set mine up to read as the following:

SelectedProfileName [COPY - RAISED/LOWERED XX'

The description will read something similar. Next we create the new profile as an ObjectId with all of the gathered information of the selected profile. Then we need to open that newly created profile and make sure the program knows to select it. Then I set the update mode to static and the description from the string above.

Now to adjust the PVIs. Here we perform a ForEach loop to check through all the PVIs in the new profile. We gather the current PVI elevation, add that to the selected value of offset (+/-), then change the PVI elevation. Finally we close the initial If/then statement with some kind of error message should the user pick a FG (finished grade profile), and commit the transaction.

See the second image below.



I'm fairly new to VB.net and the Civil3D API, so I don't know if this was the best method for this operation, but it definitely works!!

Wednesday, June 6, 2012

Eric Chappell's Blog: Upright Linetypes - Gotcha!

Here is a great post by Eric Chappell about 2012's upright linetype feature. Too bad I'm using 2011. So ready to switch!!

Eric Chappell's Blog: Upright Linetypes - Gotcha!: Recently we upgraded to Civil 3D 2012 and one of the things I was really excited about was actually an AutoCAD 2011 feature that enabled tex...

Sunday, June 3, 2012

Apply Surface Style to Multiple Surfaces in One Click

Civil 3D is a great tool. However, there are some commands and workflows that I come across during use that I think to myself "there has got to be a better way!!" One of those thoughts came to me a couple weeks ago in working with surfaces. The majority of my work is grading plans, thus I deal with a lot of surfaces. My grading plans typically consist of portions of my site (access road, pad, pits, channels, etc) all on separate surfaces, then pasted together into one compiled surface. This workflow works well when having to make modifications as you only have to work with a small area instead of a large surface.

The issue I found becomes in displaying these surfaces. The compiled surface is the one that is shown and all labels are based off of, the other surfaces are working surfaces and are only displayed when modifications are being made. Thus when coming into the drawing file I first have to turn the compiled surface to 'NO DISPLAY' then go through each of the working surfaces and turn them to a style that is displayed. Not a huge deal, but takes time and many clicks, so here's my thought - "there has to be a better way!!"

Well there is. Handle the surface displays programmatically with a new command. I'm simply calling this command 'Set Multiple Surface Styles' or from the command line, just type 'SMSS'.

Basically the command auto populates a pull down box with all the surface styles available in your current drawing and it populates a checkable list of surfaces in your current drawing. (Note: all surfaces are populated as there are four types in Civil 3D: Tin Surface, Grid Surface, Tin Volume Surface, and Grid Volume Surface.) Select the style desired and check which surfaces to apply it to, then click apply. For those that like to pick on screen, I have offered that option as well. For me personally, I've offered an expanded version of the command allowing for two different styles to be applied to surfaces all at once. (It's less clicks yet... I'm all about less clicks!!) I've also included a toolbar with a few buttons for formatting the lists; buttons include Sort, Check all, Uncheck all, and Invert Selection.

Here are some screen shots of the dialogs:


MAIN DIALOG


MAIN DIALOG


EXPANDED DIALOG


HELP MENU

As being fairly new to VB.net programming, this command was a bit difficult for me. I am currently using Civil 3D 2011, which is what the command was written in, however, it should work in older and newer versions - though it has not been tested. I initially thought I could write this command in VB.net, however the surfaces have not been fully exposed in 2011 from COM. So with a little help from JEFF_M on www.theswamp.org, he provided me with a method to call the vb.net surface and transfer it to a COM format for applying the style. Feel free to take a look at the posting here, if you'd like. This command opens up the door for other possibilities. I'm working on expanding the command for other style/object types and will post an updated version in the near future to look something like this:


FUTURE VERSION FOR ADDITIONAL STYLE/OBJECT TYPES

If you like this command and would like a copy of it you can find the DLL file here. Just type in NETLOAD in the command line and select the file. Then use "SMSS" to run the command.

If you like the command, but would like the source code for the command you can download the VB.net project here.

Feel free to let me know what you think of it!!