CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

TextAlignmentPoint Property (ActiveX)

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

摘要: 指定文本和属性的对齐点。

指定文本和属性的对齐点。

支持的平台:仅窗口

签名

工 务 局:

object.TextAlignmentPoint
对象

类型:属性,属性引用文本

此属性适用的对象。

属性值

只读:

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

表示对象对齐点的三维 WCS 坐标。

言论

文本:此属性将重置为 0, 0, 0,并在属性设置为 时变为只读。若要定位对齐对齐方式为左对齐、适合或对齐的文本,请使用 theproperty 。AlignmentacAlignmentLeftInsertionPoint

例子

工 务 局:

Sub Example_TextAlignmentPoint()
    ' This example creates a text object in model space.
    ' It then changes the TextAlignmentPoint and HorizontalAlignment
    ' properties of the text object.

    Dim textObj As AcadText
    Dim textString As String
    Dim insertionPoint(0 To 2) As Double
    Dim height As Double
    
    ' Define the text object
    textString = "Hello, World."
    insertionPoint(0) = 3: insertionPoint(1) = 3: insertionPoint(2) = 0
    height = 0.5
    
    ' Create the text object in model space
    Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
    ZoomAll
    MsgBox "The TextAlignmentPoint is set to the default " & _
           textObj.TextAlignmentPoint(0) & ", " & _
           textObj.TextAlignmentPoint(1) & ", " & _
           textObj.TextAlignmentPoint(2), vbInformation, _
           "TextAlignmentPoint Example"
    
    ' Change the value of the HorizontalAlignment and
    ' TextAlignmentPoint properties.
    ' Note that the HorizontalAlignment property must be changed first,
    ' and to a value that requires the TextAlignmentPoint, before the
    ' TextAlignmentPoint property will allow a value to be set.
    Dim alignmentPoint(0 To 2) As Double
    alignmentPoint(0) = 5: alignmentPoint(1) = 3: alignmentPoint(2) = 0
    textObj.HorizontalAlignment = acHorizontalAlignmentFit
    textObj.TextAlignmentPoint = alignmentPoint
    ZoomAll
    MsgBox "The TextAlignmentPoint is set to " & _
           textObj.TextAlignmentPoint(0) & ", " & _
           textObj.TextAlignmentPoint(1) & ", " & _
           textObj.TextAlignmentPoint(2) & vbCrLf & _
           "The HorizontalAlignment is set to acHorizontalAlignmentFit", _
           vbInformation, "TextAlignmentPoint Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_TextAlignmentPoint()
    ;; This example creates a text object in model space.
    ;; It then changes the TextAlignmentPoint and HorizontalAlignment
    ;; properties of the text object.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the text object
    (setq insertionPoint (vlax-3d-point 3 3 0)  
          textString "Hello, World."
          height 0.5)
    
    ;; Create the text object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq textObj (vla-AddText modelSpace textString insertionPoint height))  
    (vla-ZoomAll acadObj)

    (setq alignmentPoint (vlax-variant-value (vla-get-TextAlignmentPoint textObj)))
    (alert (strcat "The TextAlignmentPoint is set to the default " (rtos (vlax-safearray-get-element alignmentPoint 0) 2) ", "
                                                                   (rtos (vlax-safearray-get-element alignmentPoint 1) 2) ", "
                                                                   (rtos (vlax-safearray-get-element alignmentPoint 2) 2)))
    
    ;; Change the value of the HorizontalAlignment and
    ;; TextAlignmentPoint properties.
    ;; Note that the HorizontalAlignment property must be changed first,
    ;; and to a value that requires the TextAlignmentPoint, before the
    ;; TextAlignmentPoint property will allow a value to be set.
    (setq alignmentPoint (vlax-3d-point 5 3 0))
    (vla-put-Alignment textObj acHorizontalAlignmentFit)
    (vla-put-TextAlignmentPoint textObj alignmentPoint)
    (vla-ZoomAll acadObj)

    (setq alignmentPoint (vlax-variant-value (vla-get-TextAlignmentPoint textObj)))
    (alert (strcat "The TextAlignmentPoint is set to " (rtos (vlax-safearray-get-element alignmentPoint 0) 2) ", "
                                                       (rtos (vlax-safearray-get-element alignmentPoint 1) 2) ", "
                                                       (rtos (vlax-safearray-get-element alignmentPoint 2) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 05:22

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部