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.
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
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)
Jon,Thanks for the code.It works perfectly.Gideon
Jon,
Thanks for the code.
It works perfectly.
Gideon