CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2025 开发者帮助

Annotation 属性 (ActiveX)

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

Annotation 属性 (ActiveX)

指定引线的批注对象。

支持的平台:仅限 Windows

签名

VBA:

object.Annotation
对象

类型:领导者

此属性应用于的对象。

属性值

只读:

类型:BlockReferenceMTextTolerance

引线的批注对象。引线注释可以是公差对象、多行文本对象或块参照。

言论

并非所有引线都有批注对象。如果引线没有注释,则此属性将返回(逻辑)。若要测试 VB 或 VBA 中的逻辑值,请使用关键字。NothingFalseFalseNothing

例子

VBA:

Sub Example_Annotation()
    ' This example creates a leader in model space with an associated
    ' annotation and then checks for the existence of an
    ' Annotation object for the new Leader
   
    Dim leaderObj As AcadLeader, MTextObj As AcadMText
    Dim points(0 To 8) As Double, insertionPoint(0 To 2) As Double, width As Double
    Dim leaderType As Integer
    Dim annotationObject As Object
    Dim textString As String, msg As String
    
    ' Define the new MText object
    textString = "Hello, World."
    insertionPoint(0) = 5: insertionPoint(1) = 5: insertionPoint(2) = 0
    width = 2
    
    ' Create the MText object in model space
    Set MTextObj = ThisDrawing.ModelSpace.AddMText(insertionPoint, width, textString)
    
    ' Data for Leader
    points(0) = 0: points(1) = 0: points(2) = 0
    points(3) = 4: points(4) = 4: points(5) = 0
    points(6) = 4: points(7) = 5: points(8) = 0
    leaderType = acLineWithArrow
       
    ' Create the Leader object in model space and Associate new MText object
    ' with new Leader by making the MText object the annotation for the Leader
    Set annotationObject = MTextObj
    Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, annotationObject, leaderType)
    ThisDrawing.Application.ZoomAll

    ' Display whether or not this particular Leader has an associated Annotation
    msg = IIf(leaderObj.Annotation Is Nothing, "does not have", "has")
    MsgBox "The new Leader object " & msg & " an associated Annotation object."
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Annotation()
    ;; This example creates a leader in model space with an associated
    ;; annotation and then checks for the existence of an
    ;; Annotation object for the new Leader
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the new MText object
    (setq insertionPoint (vlax-3d-point 5 5 0)
          textString "Hello, World."
          width 2)
    
    ;; Create the MText object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq MTextObj (vla-AddMText modelSpace insertionPoint width textString))
    
    ;; Data for Leader
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 8)))
    (vlax-safearray-fill points '(0 0 0
				  4 4 0
				  4 5 0
				 ))
    (setq leaderType acLineWithArrow)
       
    ;; Create the Leader object in model space and Associate new MText object
    ;; with new Leader by making the MText object the annotation for the Leader
    (setq annotationObject MTextObj)
    (setq leaderObj (vla-AddLeader modelSpace points annotationObject leaderType))
    (vla-ZoomAll acadObj)

    (alert "The new Leader object has an associated Annotation object.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-6-27 15:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部