如果没有指定其他BlockTable,CopyObjects方法将复制对象。在下面的示例中,新文件DOC1的模型空间被设置为复制对象的目标。
- Sub danblock()
- Dim ss As AcadSelectionSet
- Dim fType(0) As Integer
- Dim fData(0) As Variant
- Dim ent As AcadEntity
-
- With ThisDrawing.SelectionSets
- While .Count > 0
- .Item(0).Delete
- Wend
- Set ss = .Add("setbom")
- End With
-
-
- fType(0) = 0
- fData(0) = "LINE,CIRCLE,INSERT,LWPOLYLINE"
- ss.SelectOnScreen fType, fData
- If ss.Count = 0 Then Exit Sub
- Dim DOC1 As AcadDocument
- Dim CurrDoc As AcadDocument
- Set CurrDoc = ThisDrawing.Application.ActiveDocument
- Set DOC1 = Documents.Add
- Dim exportFile As String
- exportFile = "C:\DXFExprt" 'Modify as needed
-
- Dim objCollection() As Object
- Dim intCount As Integer
- Dim i As Integer
- intCount = ss.Count - 1
- ReDim objCollection(intCount)
- For i = 0 To intCount
- Set objCollection(i) = ss.Item(i)
- Next
- CurrDoc.CopyObjects objCollection, DOC1.ModelSpace
- DOC1.Export exportFile, "DXF", DOC1.SelectionSets.Add("Temp")
- End Sub
|