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!!
No comments:
Post a Comment