这样么? - Public Sub test()
- On Error Resume Next Dim ft(0) As Integer, fd(0)
- Dim ss As AcadSelectionSet
- Dim Cols As New Collection
- Dim Objs As AcadBlock
- Dim pnt
- Dim strName As String
- Dim entitys(0) As AcadEntity
-
- ThisDrawing.SelectionSets("*TlsTest*").Delete
- Set ss = ThisDrawing.SelectionSets.Add("*TlsTest*")
- ft(0) = 0: fd(0) = "Circle"
- ss.Select acSelectionSetAll, , , ft, fd
-
- For Each i In ss
- pnt = i.Center
- strName = pnt(0) & "," & pnt(1) & "," & pnt(2)
- Err.Clear
- Set Objs = ThisDrawing.Blocks(Cols(strName))
- If Err Then
- Set Objs = ThisDrawing.Blocks.Add(pnt, "*U")
- Cols.Add Objs.Name, strName
- End If
- Set entitys(0) = i
- ThisDrawing.CopyObjects entitys, Objs
- Next i
-
- For Each i In Cols
- ThisDrawing.ModelSpace.InsertBlock ThisDrawing.Blocks(i).origin, i, 1, 1, 1, 0
- Next i
-
- ss.Erase
-
- End Sub
|