Toggle Structure Label Placement

Civil 3D allows one to select where a structure label should go in the settings for the Pipe Network. If you have multiple structure labels that require placement at different locations on the structure in a Profile View it can get a bit repetitive either moving the labels manually or going into the Settings and changing depending on what type of label you are going to place. After the jump I’ll go over how to create a macro to change where the structure label should be placed on the structure.

To start I’m going to use an existing VBA project called PipeRunSlope.dvb found on this page. I’m doing this for Civil 3D 2010 so the first thing up is changing the References from Civil 3D 2009 to Civil 3D 2010. (Use VBALOAD to load the dvb and VBAIDE to edit the dvb file)

image

Next I’m going to delete a bunch of the existing code and rename the SUB to ChangeStrucLabelPlacement.

image

Now change the Civil 3D version number to 7.0 and delete the rest of the code down to End Sub.

image

The code should look similar to this, except the 6.0 should be 7.0:

image

So now we can add codes of line above the End Sub line of code. The first thing to do is prompt the user where they want the structure label placement to occur (Top Bottom or Middle). To do this use the GetKeyword user prompt method of Autocad. The first thing to do is to create the Keyword list and initialize it.

Dim sKeyWordList As String
sKeyWordList = “Top Middle Bottom”
ThisDrawing.Utility.InitializeUserInput 1, sKeyWordList

The capitalized letter may be used or the user may type out the word.  Next we need to set up the set the prompt and create a variable to store the user’s input and then prompt the user.

Dim sReturnString As String
Dim sPrompt As String
sPrompt = “Structure Label Placement? (Top/Middle/Bottom): ”
sReturnString = ThisDrawing.Utility.GetKeyword(sPrompt)

Civil 3D should handle it if the user types something other than the required letters and prompt them to try again. This leaves us doing something based on what the user inputted. The first thing we need to do is get the Settings for the Pipe Network.

‘ Get the Pipe Network Settings
Dim oSettings As AeccPipeSettingsRoot
Set oSettings = oPipeDocument.Settings

Now use If Then statements to determine what the user inputted.

‘ Check to see what the user inputted and then change the label placement.
If sReturnString = “Top” Then

ElseIf sReturnString = “Middle” Then

ElseIf sReturnString = “Bottom” Then

End If

What we need to add after them is similar for all three. We need to set where the structure label should be placed. The lines of code looks similar to this:

oSettings.PipeNetworkCommandsSettings.AddNetworkPartProfLabel.ProfileLabelPlacementSettings.StructureLabelPlacement.Value = aeccAtStructureTop
oSettings.PipeNetworkCommandsSettings.AddNetworkProfLabels.ProfileLabelPlacementSettings.StructureLabelPlacement.Value = aeccAtStructureTop

The first line sets it for when a single structure is labeled and the bottom one is for when an entire pipe network structures are labeled. For the other two cases change the aeccAtStructureTop to aeccAtStructureMiddle or aeccAtStructureBottom. Now when you run the code the user will be prompted on where the structure label should be placed.

The final code should look similar to this:

image

Comments are closed.