CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

Bind 方法 (ActiveX)

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

Bind 方法 (ActiveX)

将外部参照 (外部参照) 绑定到图形。

支持的平台:仅限 Windows

签名

VBA:

object.Bind bPrefixName
对象

类型:

此方法应用到的对象。

bPrefixName

访问:仅输入

类型:布尔

  • True:符号名称不带前缀。
  • False:符号名称以 <blockname>$x$ 为前缀。

返回值 (RetVal)

无返回值。

言论

将外部参照绑定到图形将使外部参照成为图形的永久部分,而不再是外部参照文件。外部引用的信息将成为一个块。更新外部参照图形时,不会更新绑定的外部参照。此方法绑定整个图形的数据库,包括其所有从属符号。从属符号是命名对象,例如块、尺寸样式、图层、线型和文本样式。绑定外部参照允许在当前图形中使用外部参照中的命名对象。

如果 bPrefixName 参数设置为 ,则外部参照图形的符号名称在当前图形中以 <blockname>$x$ 为前缀,其中 x 是自动递增以避免覆盖现有块定义的整数。如果 bPrefixName 参数设置为 ,则外部参照图形的符号名称将合并到不带前缀的当前图形中。如果存在重复名称,AutoCAD 将使用本地图形中已定义的符号。如果不确定图形是否包含重复的符号名称,建议将 bPrefixName 设置为 。FalseTrueFalse

例子

VBA:

Sub Example_Bind()
    On Error GoTo ERRORHANDLER
                          
    ' Define external reference to be inserted
    Dim xrefHome As AcadBlock
    Dim xrefInserted As AcadExternalReference
    Dim insertionPnt(0 To 2) As Double
    Dim PathName As String
    insertionPnt(0) = 1
    insertionPnt(1) = 1
    insertionPnt(2) = 0
    PathName = "c:/AutoCAD/sample/City map.dwg"
    
    ' Add the external reference
    Set xrefInserted = ThisDrawing.ModelSpace. _
            AttachExternalReference(PathName, "XREF_IMAGE", _
            insertionPnt, 1, 1, 1, 0, False)
    ZoomAll
    MsgBox "The external reference is attached."
    
    ' Bind the external reference definition
    ThisDrawing.Blocks.Item(xrefInserted.name).Bind False
    MsgBox "The external reference is bound."
    Exit Sub
ERRORHANDLER:
    MsgBox Err.Description
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Bind()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
                          
    ;; Define external reference to be inserted
    (setq insertionPnt (vlax-3d-point 1 1 0)
          pathName (findfile ".\\Sample\\Sheet Sets\\Architectural\\Res\\STAIR1.dwg"))

    ;; Add the external reference
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq xrefInserted (vla-AttachExternalReference modelSpace pathName "XREF_IMAGE" insertionPnt 1 1 1 0 :vlax-false))
    (vla-ZoomAll acadObj)
    (alert "The external reference is attached.")
    
    ;; Bind the external reference definition
    (vla-Bind (vla-Item (vla-get-Blocks doc) (vla-get-Name xrefInserted)) :vlax-false)
    (alert "The external reference is bound.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-14 08:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部