今天刚写的代码,发上来和大家共享一下。
-
- Public Sub LJ()
- Dim SsLine As AcadSelectionSet
- Dim FilterType(0) As Integer
- Dim FilterData(0) As Variant
- CertificationSelect "ST"
- Set SsLine = ThisDrawing.SelectionSets.Add("ST")
- FilterType(0) = 0
- FilterData(0) = "LINE"
- SsLine.SelectOnScreen FilterType, FilterData
- Do While LineJoin(SsLine)
- Loop
- Set SsLine = Nothing
- End Sub
- Public Function LineJoin(ByVal SS As AcadSelectionSet) As Boolean
- If SS.Count EndPoint(0) Then
- EndPoint(0) = Points(n)
- EndPoint(1) = Points(n + 1)
- End If
- If Points(n) = EndPoint(0) And Points(n + 1) > EndPoint(1) Then
- EndPoint(1) = Points(n + 1)
- End If
- Next
- Set LineObjs(0) = ThisDrawing.ModelSpace.AddLine(StartPoint, EndPoint)
- LineObjs(0).Layer = SS(i).Layer
- SS.AddItems LineObjs
- Set DelObjs(0) = SS(i)
- Set DelObjs(1) = SS(j)
- SS.RemoveItems DelObjs
- SS.Update
- DelObjs(0).Delete
- DelObjs(1).Delete
- LineJoin = True
- Exit Function
- End If
- End If
- Next
- Next
- LineJoin = False
- End Function
|