Sub block() Dim Po() As Double Dim ss As AcadSelectionSet Dim Bk As AcadBlock
On Error Resume Next
Po(0) = 0 Po(1) = 0 Po(2) = 0
'ThisDrawing.Blocks.Item("ok").Delete
Set Bk = ThisDrawing.Blocks.Add(Po, "tempb")
Set ss = ThisDrawing.SelectionSets.Item("ssss") '------------------------------------------------ If Err Then Err.Clear Set ss = ThisDrawing.SelectionSets.Add("ssss") End If '------------------------------------------------ ss.Select acSelectionSetAll '------------------------------------------------过滤对象 Dim retVal() As AcadEntity Dim Ent As AcadEntity
Dim i As Integer i = 0
ReDim retVal(0 To ss.Count - 1) For Each Ent In ss If (Ent.Layer = "layer") Then Set retVal(i) = Ent Ent.Delete i = i + 1 End If Next ReDim Preserve retVal(0 To i - 1)
'------------------------------------------------ MsgBox "shiti" & ss.Count ThisDrawing.CopyObjects retVal(), Bk ' 在这里出问题了 MsgBox "bk" & Bk.Count ThisDrawing.ModelSpace.InsertBlock Po, "tempb", 1, 1, 1, 90 ss.Delete MsgBox "end" End Sub
|