CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

字段长度属性 (ActiveX)

2023-1-3 16:35| 发布者: admin| 查看: 454| 评论: 0|来自: AutoCAD

摘要: 指定属性的字段长度。

指定属性的字段长度。

支持的平台:仅窗口

签名

工 务 局:

object.FieldLength
对象

类型:属性,属性引用

此属性适用的对象。

属性值

只读:

类型:整数

属性的字段长度。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_FieldLength()
    ' This example creates an attribute definition in model space.
    ' It then queries the initial value of the FieldLength property,
    ' changes that value, and finally resets the value.
    
    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
    
    ' Return the current field length of the attribute
    Dim currFieldLength As Integer
    currFieldLength = attributeObj.FieldLength
    MsgBox "The FieldLength of the attribute is " & attributeObj.FieldLength, vbInformation, "FieldLength Example"
    
    ' Change the field length
    attributeObj.FieldLength = currFieldLength + 2
    attributeObj.Update
    MsgBox "The new FieldLength of the attribute is " & attributeObj.FieldLength, vbInformation, "FieldLength Example"
    
    ' Reset the field length to the original value
    attributeObj.FieldLength = currFieldLength
    attributeObj.Update
    MsgBox "The FieldLength of the attribute is reset to " & attributeObj.FieldLength, vbInformation, "FieldLength Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_FieldLength()
    ;; This example creates an attribute definition in model space.
    ;; It then queries the initial value of the FieldLength property,
    ;; changes that value, and finally resets the value.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the attribute definition
    (setq insertionPoint (vlax-3d-point 5 5 0)
          height 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 height attMode attPrompt insertionPoint attTag attValue))
    (vla-ZoomAll acadObj)
    
    ;; Return the current field length of the attribute
    (setq currFieldLength (vla-get-FieldLength attributeObj))
    (alert (strcat "The FieldLength of the attribute is " (itoa currFieldLength)))
    
    ;; Change the field length
    (setq newFieldLength (+ currFieldLength 2))
    (vla-put-FieldLength attributeObj newFieldLength)
    (vla-Update attributeObj)
    (alert (strcat "The new FieldLength of the attribute is " (itoa newFieldLength)))
    
    ;; Reset the field length to the original value
    (vla-put-FieldLength attributeObj currFieldLength)
    (vla-Update attributeObj)
    (alert (strcat "The FieldLength of the attribute is reset to " (itoa currFieldLength)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部