使用选择创建dxf文件
您好,我喜欢在VBA中生成自己的WBLOCK命令。我需要选择实体(线,圆,线,块),并把它放在2个新的dxf文件,将由其他程序使用。此图纸。Wblock命令仅生成DWG和ThisDrawing。导出可以生成DXF,但包含所有源DWG。
我尝试从源DWG中进行选择,将其复制到临时文件以制作此图形。与该文件一起导出。但是当我试着这样做时,副本会被放入我的源文件中。。。。。为什么?
如果你有其他想法,不要说。
自制wblock。txt文件 如果没有指定其他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 谢谢你的帮助。我的功能运行得很好。在制作DXF之前,我试图找到缩放选择的方法。我必须用我选择的相同比例制作一个dxf,另一个以毫米为单位,因此,我需要将我的选择比例放大25.4倍
页:
[1]