Public Sub P_Length() Dim acadObj As Object Dim pline As AcadLWPolyline Dim plineCopy As AcadLWPolyline Dim aa As AcadLWPolyline Dim explodedObjects As Variant Dim lineObj As AcadLine Dim length, length_Object As Double length = 0# length_Object = 0# For Each acadObj In ThisDrawing.ModelSpace If acadObj.ObjectName = "AcDbPolyline" Then 'If acadObj.ObjectName = "AcDbPolyline" Then Set pline = acadObj Set plineCopy = pline.Copy() explodedObjects = plineCopy.Explode plineCopy.Delete Dim i As Integer For i = 0 To UBound(explodedObjects) Set lineObj = explodedObjects(i) length = length + lineObj.length length_Object = length_Object + lineObj.length explodedObjects(i).Delete Next ThisDrawing.Utility.Prompt "长度=" & CStr(length_Object) & (Chr(13) & Chr(10)) End If length_Object = 0# Next acadObj ThisDrawing.Utility.Prompt "总长度=" & CStr(length) End Sub 你的plineCopy.Delete也写错了。 |