CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

导入方法 (ActiveX)

2023-1-4 06:12| 发布者: admin| 查看: 733| 评论: 0|来自: AutoCAD

摘要: 从文件输入图形或一组已保存的图层设置。

从文件输入图形或一组已保存的图层设置。

支持的平台:仅窗口

签名 - 文档

工 务 局:

RetVal = object.Import(FileName, InsertionPoint, ScaleFactor)
对象

类型:文档

此方法适用的对象。

文件名

访问:仅输入

类型:字符串

要导入的文件的名称。

插入点

访问:仅输入

类型:变体(双精度的三元素数组)

3D WCS 可协调当前图形中放置输入文件的位置。

比例因子

访问:仅输入

类型:

用于放置导入文件的比例。

签名 - 层状态管理器

工 务 局:

object.Import FileName
对象

类型:层状态管理器

此方法适用的对象。

文件名

访问:仅输入

类型:字符串

要从中导入图层设置的文件的名称。

返回值 (RetVal) - 文档

类型:对象

在导入 WMF 文件的情况下,将返回一个对象。在所有其他情况下,返回值为 NULL。BlockReference

返回值 (RetVal) - 层状态管理器

无返回值。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_Import()
    ' This example will create a new drawing. Be sure to save
    ' your work and start a new drawing before running this example.
    ' This example creates a circle. It then exports the drawing
    ' to a file called DXFExport.DXF. It then opens a new drawing
    ' and imports the file.
    
    ' 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)
    ZoomAll
    
    ' Create an empty selection set
    Dim sset As AcadSelectionSet
    Set sset = ThisDrawing.SelectionSets.Add("TEST")
    
    ' Export the current drawing to the file specified above.
    Dim exportFile As String
    exportFile = "C:\AutoCAD\DXFExport"    ' Adjust path for your system
    ThisDrawing.Export exportFile, "DXF", sset
    
    ' Open a new drawing
    Dim Acad As AcadApplication
    Dim newdoc As AcadDocument
    Set Acad = ThisDrawing.Application
    Set newdoc = Acad.Documents.Add("acad.dwt")
    
    ' Define the import
    Dim importFile As String
    Dim InsertPoint(0 To 2) As Double
    Dim scalefactor As Double
    importFile = "C:\AutoCAD\DXFExport.dxf"  ' Adjust path for your system
    InsertPoint(0) = 0#: InsertPoint(1) = 0#: InsertPoint(2) = 0#
    scalefactor = 2#
    
    ' Import the file
    ThisDrawing.Import importFile, InsertPoint, scalefactor
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Import()
    ;; This example will create a new drawing. Be sure to save
    ;; your work and start a new drawing before running this example.
    ;; This example creates a circle. It then exports the drawing
    ;; to a file called DXFExport.DXF. It then opens a new drawing
    ;; and imports the file.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Create the circle for visual representation
    (setq centerPt (vlax-3d-point 2 2 0))  
    (setq radius 1)
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circleObj (vla-AddCircle modelSpace centerPt radius))
    (vla-ZoomAll acadObj)
    
    ;; Create an empty selection set
    (setq sset (vla-Add (vla-get-SelectionSets doc) "TEST"))
    
    ;; Export the current drawing to the file specified above.
    (setq exportFile "C:\\AutoCAD\\DXFExport")    ;; Adjust path for your system
    (vla-Export doc exportFile "DXF" sset)
    
    ;; Define the import
    (setq insertPoint (vlax-3d-point 0 0 0))  
    (setq importFile "C:\\AutoCAD\\DXFExport.dxf"  ;; Adjust path for your system
          scalefactor 2)
    
    ;; Import the file
    (vla-Import doc importFile insertPoint scalefactor)
    (vla-ZoomAll acadObj)

    (vla-Delete sset)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-11 20:37

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部