如果需要在其他应用程序中使用 AutoCAD 图形,可以使用该方法将其转换为特定格式。Export 该方法将 AutoCAD 图形导出为 WMF、SAT、EPS、DXF 或 BMP 格式。该方法采用三个值作为输入:要创建的新文件的名称、新文件的扩展名以及要导出的对象的选择集。ExportExport 导出为 WMF、SAT 或 BMP 格式时,必须提供非空选择集。此选择集指定图形中要输出的对象。如果未指定选择集,则不会导出任何内容,并导致可捕获的无效参数错误。 导出为 EPS 和 DXF 格式时,“导出”将忽略选择集参数,但仍是必需的。将自动导出为这些格式的整个图形。 将图形输出为 DXF 文件,然后再次输入本示例在当前图形中创建一个圆。然后,它将图形导出到名为 DXFExprt.dxf 的文件中,打开一个新图形,然后导入该文件。请注意,将提供一个空选择集作为导出的参数。该方法在导出 DXF 文件时忽略选择集信息,但如果省略参数,则会导致语法错误。Export Sub Ch3_ImportingAndExporting() ' Create the circle for visual representation Dim circleObj As AcadCircle Dim centerPt(0 To 2) As Double Dim radius As Double centerPt(0) = 2: centerPt(1) = 2: centerPt(2) = 0 radius = 1 Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPt, radius) ThisDrawing.Application.ZoomAll ' Create an empty selection set Dim sset As AcadSelectionSet Set sset = ThisDrawing.SelectionSets.Add("NEWSSET") ' Export the current drawing to a DXF file in the ' AutoCAD temporary file directory Dim tempPath As String Dim exportFile As String Const dxfname As String = "DXFExprt" tempPath = ThisDrawing.Application.preferences.Files.TempFilePath exportFile = tempPath & dxfname ThisDrawing.Export exportFile, "DXF", sset ' Delete the empty selection set ThisDrawing.SelectionSets.Item("NEWSSET").Delete ' Open a new drawing ThisDrawing.Application.Documents.Add "acad.dwt" ' Define the import Dim importFile As String Dim insertPoint(0 To 2) As Double Dim scalefactor As Double importFile = tempPath & dxfname & ".dxf" insertPoint(0) = 0: insertPoint(1) = 0: insertPoint(2) = 0 scalefactor = 2# ' Import the file ThisDrawing.Import importFile, insertPoint, scalefactor ThisDrawing.Application.ZoomAll End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:50
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.