getting linestring points

Hi All,

has anyone got a macro that lists all linestring points?

I am looking for a tool that would work like this:

1. I select some linestrings in MicroStation

2. I run a macro while linestrings are selected

3. The macro produces .txt file:

string 1

234545.324 54645.232 12.324

223545.346 56567.234 13.545

235445.346 56887.234 15.573

 

string 2

268845.324 54445.232 13.324

229845.346 56337.234 14.545

235225.346 56227.234 17.573

 

Can anyone help with it? Macro or any tip how to do it will be greatly apreciated. Thank.

Parents Reply
  • Hi,

    code snippet:

    Sub Start()

    Open "C:\\path_to_your_file\\output_file.txt" For Output As #1

    Dim esc As ElementScanCriteria
    Set esc = New ElementScanCriteria
    esc.ExcludeAllTypes
    esc.IncludeType msdElementTypeLineString
     
    Dim ee As ElementEnumerator
    Set ee = ActiveModelReference.Scan(esc)

    Dim el As LineElement

    Dim stringNum As Long
    stringNum = 1

    Do While ee.MoveNext
        Print #1, "String " + CStr(stringNum)
        
        Dim vertices As Long
        vertices = ee.Current.AsLineElement.VerticesCount
        
        Dim points() As Point3d
        points = ee.Current.AsLineElement.GetVertices
        
        Dim index As Long
        For index = 0 To vertices - 1
            Print #1, CStr(points(index).X) + " " + CStr(points(index).Y) + " " + CStr(points(index).Z)
        Next
        
        stringNum = stringNum + 1
    Loop

    Close #1

    End Sub

    With regards,

      Jan

Children