Measure lines

What code do I have to create in mvba to measure all lines on a specified level.

e.g.

I want to measure the total length of all the lines/linestrings on a specified level.

Parents Reply Children
  • Measure Length will give you a cumulative length of all elements selected, so if you have mvba to select the elements you can get total length with this tool (on measure taskbar or keyin: Measure Length)

    Brent

  • Hello Jon,

    I found your example, but how can I get the total lengt of all measured lines [how can I get the x value].

    see example:

    ------------------------------------------------------------------------------------------------------------------------------------

    Sub ScanLineLength()

       ActiveModelReference.UnselectAllElements

       Dim ScanLinesByLength As Long

       Dim oCriteria As New ElementScanCriteria

           oCriteria.ExcludeNonGraphical

           oCriteria.ExcludeAllTypes

           oCriteria.IncludeType msdElementTypeLine

       Dim oLines As ElementEnumerator

           Set oLines = ActiveModelReference.Scan(oCriteria)

       While (oLines.MoveNext)

           Dim oLine As LineElement

               Set oLine = oLines.Current.AsLineElement

       MsgBox ("lengte is : " & oLine.Length)

       Wend

       MsgBox ("total length is : " & "x")

    End Sub

    ------------------------------------------------------------------------------------------------------------------------------------

    Gideon.

  • Try something like this …

     Dim totalLength As Double
    totalLength = 0.0
    While (oLines.MoveNext)
       Dim oLine As LineElement
       Set oLine = oLines.Current.AsLineElement
       totalLength = totalLength + oLine.Length
      
    Wend
    Debug.Print "Total length=" & CStr (totalLength)

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Jon,Thanks for the code.It works perfectly.Gideon