CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

AttachExternalReference 方法 (ActiveX)

2024-5-18 18:55| 发布者: admin| 查看: 102| 评论: 0|原作者: admin|来自: AutoCAD

AttachExternalReference 方法 (ActiveX)

将外部参照 (外部参照) 附着到绘图中。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.AttachExternalReference(PathName, Name, InsertionPoint, XScale, YScale, ZScale, Rotation, Overlay [, Password])
对象

类型:模型空间纸空间

此方法应用到的对象。

路径

访问:仅输入

类型:字符串

要参照的图形的完整路径和文件名。

名字

访问:仅输入

类型:字符串

要创建的外部参照的名称。

插入点

访问:仅输入

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

3D WCS 坐标指定将实例插入到图形中的点。当前图形中的插入点与参照文件中 AutoCAD BASE 系统变量定义的点对齐。ExternalReference

XScale的

访问:仅输入

类型:

外部参照实例的 X 比例因子。

YScale(英语:YScale)

访问:仅输入

类型:

外部参照实例的 Y 比例因子。

ZScale(ZScale)

访问:仅输入

类型:

外部参照实例的 Z 比例因子。

旋转

访问:仅输入

类型:

外部参照实例的旋转角度。此角度以弧度指定。

覆盖

访问:仅输入

类型:布尔

  • True:外部参照实例是叠加。
  • False:外部参照实例是附件。
密码

访问:仅输入;自选

类型:变体

;自选

返回值 (RetVal)

类型:ExternalReference

新创建的对象。ExternalReference

言论

与对象一样,附加对象也可以嵌套。如果其他人正在编辑要参照的图形,则附加的图形将基于最近保存的版本。BlockExternalReference

如果参照文件丢失或损坏,则其数据不会显示在当前图形中。

例子

VBA:

Sub Example_AttachExternalReference()
    ' This example displays all the blocks in the current drawing
    ' before and after adding an external reference.
    '
    ' This example uses the "city map.dwg" found in the Sample
    ' directory. If you do not have this drawing, or if it is 
    ' in a different directory, insert a valid path and file name
    ' for the PathName variable below.
    
    Dim InsertPoint(0 To 2) As Double
    Dim insertedBlock As AcadExternalReference
    Dim tempBlock As AcadBlock
    Dim msg As String, PathName As String
    
    ' Define external reference to be inserted
    InsertPoint(0) = 1: InsertPoint(1) = 1: InsertPoint(2) = 0
    PathName = "c:\program files\autocad\sample\city map.dwg"
    
    ' Display current Block information for this drawing
    GoSub ListBlocks
    
    ' Add the external reference to the drawing
    Set insertedBlock = ThisDrawing.ModelSpace.AttachExternalReference(PathName, "XREF_IMAGE", InsertPoint, 1, 1, 1, 0, False)
        
    ThisDrawing.Application.ZoomAll
    
    ' Display new Block information for this drawing
    GoSub ListBlocks
    
    Exit Sub

ListBlocks:
    msg = vbCrLf    ' Reset message
    
    For Each tempBlock In ThisDrawing.Blocks
        msg = msg & tempBlock.name & vbCrLf     ' Add Block to list
    Next
    
    MsgBox "The current blocks in this drawing are: " & msg
    
    Return
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_AttachExternalReference()
    ;; This example displays all the blocks in the current drawing
    ;; before and after adding an external reference.
    ;;
    ;; This example uses the "STAIR1.dwg" found in the Sample
    ;; directory. If you do not have this drawing, or if it is 
    ;; in a different directory, insert a valid path and file name
    ;; for the PathName variable below.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define external reference to be inserted
    (setq InsertPoint (vlax-3d-point 1 1 0))
    (setq pathName (findfile ".\\Sample\\Sheet Sets\\Architectural\\Res\\STAIR1.dwg"))
    
    ;; Display current Block information for this drawing
    (setq msg "")
    (vlax-for tempBlock (vla-get-Blocks doc)
        (setq msg (strcat msg (vla-get-Name tempBlock) "\n"))     ;; Add Block to list
    )
    
    (alert (strcat "The current blocks in this drawing are: " msg))
    
    ;; Add the external reference to the drawing
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq insertedBlock (vla-AttachExternalReference modelSpace pathName "XREF_IMAGE" InsertPoint 1 1 1 0 :vlax-false))
        
    (vla-ZoomAll acadObj)
    
    ;; Display new Block information for this drawing
    (setq msg "")
    (vlax-for tempBlock (vla-get-Blocks doc)
        (setq msg (strcat msg (vla-get-Name tempBlock) "\n"))     ;; Add Block to list
    )
    
    (alert (strcat "The current blocks in this drawing are: " msg))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-5 17:47

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部