multiline styles names

i have 3 linestyles in a dgn file so is it possible to find out how many linestyles do i have and what are their names using vba.

Parents Reply Children
  • As I know, MultiLine styles are not supported by MVBA, but as in all stuff like this, you can use VBA Wrapper declarations for methods from MDL (MicroStation Development Library). To get access to those declarations, you need MicroStation SDK installed. It can be found on select server... Then in Documentation directory you can find file MDLAPIFunctionReference.chm that contains information, how to declare which function. Unfortunately, there are only examples how to use them in MDL Programming. To use those functions in VBA, you need some C knowledge, because logic and syntax used in MDL is derived from C...
  • Paste the following code into module. Can NOT be placed into class or form (form is class as well)...

    Then run GetMLineAll...  

    Techniques used in the following example are NOT recommended for those VBA users, who don't know, how it works.  

    Declare Sub MoveMemory Lib "kernel32" _
         Alias "RtlMoveMemory" _
         (ByVal strDest As Any, _
         ByVal lpSource As Any, _
         ByVal length As Long)
         
    Type MLineStyleNames
        Count As Long
        Names() As String
    End Type
         
    Function TrimNullChar(InputStr As StringAs String
        TrimNullChar = Left$(InputStr, InStr(1, InputStr, vbNullChar) - 1)
    End Function

    Function TraverseFunction(ByRef MayContinue As LongByVal mlineStyleP As Long, _
                              ByVal MSWNameP As LongByRef Styles As MLineStyleNames) As Long
        On Error Resume Next
        Dim Buffer As String
        Buffer = String(256, vbNullChar)
        MoveMemory StrPtr(Buffer), MSWNameP, 256
        
        With Styles
            ReDim Preserve .Names(.Count)
            .Names(.Count) = TrimNullChar(Buffer)
            If .Names(.Count) = "" Then .Names(.Count) = "Default"
            .Count = .Count + 1
        End With
        
        MayContinue = 1
        TraverseFunction = 0
    End Function

    Function GetMultiLineStyles(MR As ModelReference) As MLineStyleNames
        Dim CExpression As String
        CExpression = "mdlMlineStyle_traverse(" & Val(AddressOf TraverseFunction) & ", " & _
                                VarPtr(GetMultiLineStyles) & ", " & MR.MdlModelRefP & ", -1)"
        GetCExpressionValue CExpression
    End Function

    Sub GetMLineAll()

        Dim Styles As MLineStyleNames
        Dim i As Long
        
        Styles = GetMultiLineStyles(ActiveModelReference)
        
        If Styles.Count > 0 Then
            For i = 0 To Styles.Count - 1
                MsgBox i + 1 & " - " & Styles.Names(i)
            Next i
        End If

    End Sub
  • Awful! This is what i want exactly.
    Thank you so much, Don.

     

  • Dan, but it doesn't matter, because my original name is Dušan :)
  • I'm sorry for little mistake Dušan (Dan).

    And again God bless you :)