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
  • Measure Elements

    Although not an exact match to your question, we posted some VBA Examples that measure elements (search for 'measure' on that web page). You can probably adapt one of the examples to scan for LineElements on a specified Level. For each LineElement, do something with LineElement.Length.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • 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

Reply Children
No Data