CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2021 开发者帮助

TagString 属性 (ActiveX)

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

TagString 属性 (ActiveX)

指定对象的标记字符串。

支持的平台:仅限 Windows

签名

VBA:

object.TagString
对象

类型:AttributeAttributeReferencePopupMenuPopupMenuItemToolbar、ToolbarItem

此属性应用于的对象。

属性值

只读:不;除了 和 对象PopupMenuToolbar

类型:字符串

对象的标记字符串。

言论

Attribute, AttributeReference:此字符串标识属性的每次匹配项。输入除空格或感叹号以外的任何字符。AutoCAD 将小写字母更改为大写字母。

PopupMenu、PopupMenuItem、Toolbar、ToolbarItem:标记或名称标记是由字母数字和下划线 (_) 字符组成的字符串。此字符串唯一标识给定自定义文件中的项。此字符串在创建对象时自动指定,并由 AutoCAD 在内部用于工具栏和菜单标识。大多数开发商不需要这种级别的身份证明,可以安全地忽略该物业。TagString

例子

VBA:

Sub Example_TagString()
    ' This example creates an attribute definition in model space.
    ' It then queries the tag string for the attribute, changes
    ' the tag string, and displays the new tag string.
    
    Dim attributeObj As AcadAttribute
    Dim height As Double
    Dim mode As Long
    Dim prompt As String
    Dim insertionPoint(0 To 2) As Double
    Dim tag As String
    Dim value As String
    
    ' Define the attribute definition
    height = 1#
    mode = acAttributeModeVerify
    prompt = "New Prompt"
    insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0
    tag = "NEW_TAG"
    value = "New Value"
    
    ' Create the attribute definition object in model space
    Set attributeObj = ThisDrawing.ModelSpace.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
    ZoomAll
    
    ' Find the current tag string for the attribute
    tag = attributeObj.TagString
    MsgBox "The current tag string for the attribute is " & tag, , "TagString Example"
    
    ' Change the tag string for the attribute
    attributeObj.TagString = "UPDATED_TAG"
    attributeObj.Update
    tag = attributeObj.TagString
    MsgBox "The new tag string for the attribute is " & tag, , "TagString Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_TagString()
    ;; This example creates an attribute definition in model space.
    ;; It then queries the tag string for the attribute, changes
    ;; the tag string, and displays the new tag string.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the attribute definition
    (setq insertionPoint (vlax-3d-point 5 5 0) 
          attHeight 1
          attMode acAttributeModeVerify
          attPrompt "New Prompt"
          attTag "NEW_TAG"
          attValue "New Value")
    
    ;; Create the attribute definition object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq attributeObj (vla-AddAttribute modelSpace attHeight attMode attPrompt insertionPoint attTag attValue))
    (vla-ZoomAll acadObj)
    
    ;; Find the current tag string for the attribute
    (setq tag (vla-get-TagString attributeObj))
    (alert (strcat "The current tag string for the attribute is " tag))
    
    ;; Change the tag string for the attribute
    (vla-put-TagString attributeObj "UPDATED_TAG")
    (vla-Update attributeObj)
    (setq tag (vla-get-TagString attributeObj))
    (alert (strcat "The new tag string for the attribute is " tag))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:32

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部