-
- Sub tn = (UBound(cor3) + 1) * 2 / 3
- Dim pt() As Double
- ReDim pt(0 To n - 1) As Double
- For i = 0 To (n - 2) Step 2
这里太乱了,改为sub test3Dto2D()
'创建选择集
Dim selset As AcadSelectionSet
Dim cor3 As Variant
Dim n As Integer
Set selset = ThisDrawing.SelectionSets.Add("sset")
selset.Select acSelectionSetAll '遍历选择集并将每一个对象镜相
Dim entry As AcadObject
Dim pl As AcadLWPolylineFor Each entry In selset
If entry.EntityName = "AcDb3dPolyline" Then
cor3 = entry.Coordinates
n = (UBound(cor3) + 1) / 3
Dim pt() As Double
ReDim pt(0 To n * 2 - 1) As Double For i = 0 To n - 1
pt(i * 2) = cor3(i * 3)
pt(i * 2 + 1) = cor3(i * 3 + 1)
Next i
Set pl = ThisDrawing.ModelSpace.AddLightWeightPolyline(pt)
entry.Delete
End If
Next entryselset.Delete '避免下次重复End Sub |