You are currently reviewing an older revision of this page.
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 Doublesum = 0Dim ee As ElementEnumeratorDim Sc As New ElementScanCriteriaSc.ExcludeAllTypesSc.IncludeType msdElementTypeArcSet ee = ActiveModelReference.GraphicalElementCache.Scan(Sc)Do While ee.MoveNext sum = sum + ee.Current.AsArcElement.LengthLoopIf sum = 0 Then MsgBox "No Sheets Found", vbOKOnlyElse MsgBox "Total length of all sheets: " & sum, vbOKOnly Debug.Print sumEnd IfEnd 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.