SetLine

From Microstation VBA Wiki
Jump to: navigation, search

This subroutine takes a string which represents some kind of line type defined by the programmer and and changes the Microstation settings so that the next time a line is placed it will be the correct color, line weight, line type, and on the correct level. Some of this is explained in lines. The function is called by a line like this:

SetLine("Dimension")

Here is the subroutine:

Private Sub SetLine(strType As String)

Dim oLevel As Level
Dim oLineStyle As LineStyle

Select Case strType
    Case "Concrete"
        Set oLevel = ActiveDesignFile.Levels.Find("Level 2")
        Set ActiveSettings.Level = oLevel
        ActiveSettings.LineWeight = 4
        Set oLineStyle = ActiveDesignFile.LineStyles.Find("0")
        Set ActiveSettings.LineStyle = oLineStyle
        ActiveSettings.Color = 0 'White
        
    Case "Center"
        Set oLevel = ActiveDesignFile.Levels.Find("Level 5")
        Set ActiveSettings.Level = oLevel
        ActiveSettings.LineWeight = 1
        Set oLineStyle = ActiveDesignFile.LineStyles.Find("6")
        Set ActiveSettings.LineStyle = oLineStyle
        ActiveSettings.Color = 2 'Lime
        
    Case "Dimension"
        Set oLevel = ActiveDesignFile.Levels.Find("Level 7")
        Set ActiveSettings.Level = oLevel
        ActiveSettings.LineWeight = 1
        Set oLineStyle = ActiveDesignFile.LineStyles.Find("0")
        Set ActiveSettings.LineStyle = oLineStyle
        ActiveSettings.Color = 3 'Red

    Case Else
        MsgBox "No such line type for " & strType

    End Select
End Sub