We are often faced with the task of knowing the lengths of certain elements in a drawing.Here is a simple example using VBA that adds up the length of all existing arcs in the active model sheets.
Sub arcLength() Dim sum As Double sum = 0 Dim ee As ElementEnumerator Dim Sc As New ElementScanCriteria Sc.ExcludeAllTypes Sc.IncludeType msdElementTypeArc Set ee = ActiveModelReference.GraphicalElementCache.Scan(Sc) Do While ee.MoveNext sum = sum + ee.Current.AsArcElement.Length Loop If sum = 0 Then MsgBox "No Sheets Found", vbOKOnly Else MsgBox "Total length of all sheets: " & sum, vbOKOnly Debug.Print sum End If End Sub
In the above example, the active arcs' model is read, and then the lengths of the individual active arcs are read and added together.The result is displayed in a dialog box, or if no sheet has been found that is specified.