CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

对齐属性 (ActiveX)

2023-1-3 23:45| 发布者: admin| 查看: 442| 评论: 0|来自: AutoCAD

摘要: 指定属性、属性引用或文本的垂直和水平对齐方式。

指定属性、属性引用或文本的垂直和水平对齐方式。

支持的平台:仅窗口

签名

工 务 局:

object.Alignment
对象

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

此属性适用的对象。

属性值

只读:

类型:枚举acAlignment

  • acAlignmentLeft
  • acAlignmentCenter
  • acAlignmentRight
  • acAlignmentAligned
  • acAlignmentMiddle
  • acAlignmentFit
  • acAlignmentTopLeft
  • acAlignmentTopCenter
  • acAlignmentTopRight
  • acAlignmentMiddleLeft
  • acAlignmentMiddleCenter
  • acAlignmentMiddleRight
  • acAlignmentBottomLeft
  • acAlignmentBottomCenter
  • acAlignmentBottomRight

言论

对齐的文本使用属性来定位文本。acAlignmentLeftInsertionPoint

对齐的文本使用和属性来定位文本。acAlignmentAlignedacAlignmentFitInsertionPointTextAlignmentPoint

与任何其他位置对齐的文本使用该属性来定位文本。TextAlignmentPoint



例子

工 务 局:

Sub Example_Alignment()
   ' This example creates a text object in model space and
   ' demonstrates setting the alignment of the new text string
    
    Dim textObj As AcadText
    Dim textString As String
    Dim insertionPoint(0 To 2) As Double, alignmentPoint(0 To 2) As Double
    Dim height As Double
    Dim oldPDMODE As Integer
    Dim pointObj As AcadPoint
    
    ' Define the new Text object
    textString = "Hello, World."
    insertionPoint(0) = 3: insertionPoint(1) = 3: insertionPoint(2) = 0
    alignmentPoint(0) = 3: alignmentPoint(1) = 3: alignmentPoint(2) = 0
    height = 0.5
    
    ' Create the Text object in model space
    Set textObj = ThisDrawing.ModelSpace.AddText(textString, insertionPoint, height)
    
    oldPDMODE = ThisDrawing.GetVariable("PDMODE")   ' Record existing point style
    
    ' Create a crosshair over the text alignment point
    ' to better visualize the alignment process
    Set pointObj = ThisDrawing.ModelSpace.AddPoint(alignmentPoint)
    
    ThisDrawing.SetVariable "PDMODE", 2             ' Set point style to crosshair
        
    ThisDrawing.Application.ZoomAll
    
    ' Set the text alignment to a value other than acAlignmentLeft, which is the default.
    ' Create a point that will act as an alignment reference point
    textObj.Alignment = acAlignmentRight
    
    ' Create the text alignment reference point and the text will automatically
    ' align to the right of this point, because the text
    ' alignment was set to acAlignmentRight
    textObj.TextAlignmentPoint = alignmentPoint
    ThisDrawing.Regen acActiveViewport
    MsgBox "The Text object is now aligned to the right of the alignment point"
    
    ' Center the text to the alignment point
    textObj.Alignment = acAlignmentCenter
    ThisDrawing.Regen acActiveViewport
    MsgBox "The Text object is now centered to the alignment point"
    
    ' Reset point style
    ThisDrawing.SetVariable "PDMODE", oldPDMODE
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Alignment()
   ;; This example creates a text object in model space and
   ;; demonstrates setting the alignment of the new text string
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the new Text object
    (setq insertionPoint (vlax-3d-point 3 3 0)  
          alignmentPoint (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))
    
    (setq oldPDMODE (vlax-variant-value (vla-GetVariable doc "PDMODE")))   ;; Record existing point style
    
    ;; Create a crosshair over the text alignment point
    ;; to better visualize the alignment process
    (setq pointObj (vla-AddPoint modelSpace alignmentPoint))
    
    (vla-SetVariable doc "PDMODE" 2)             ;; Set point style to crosshair
        
    (vla-ZoomAll acadObj)
    
    ;; Set the text alignment to a value other than acAlignmentLeft, which is the default.
    ;; Create a point that will act as an alignment reference point
    (vla-put-Alignment textObj acAlignmentRight)
    
    ;; Create the text alignment reference point and the text will automatically
    ;; align to the right of this point, because the text
    ;; alignment was set to acAlignmentRight
    (vla-put-TextAlignmentPoint textObj alignmentPoint)
    (vla-Regen doc acActiveViewport)
    (alert "The Text object is now aligned to the right of the alignment point.")
    
    ;; Center the text to the alignment point
    (vla-put-Alignment textObj acAlignmentCenter)
    (vla-Regen doc acActiveViewport)
    (alert "The Text object is now centered to the alignment point.")
    
    ;; Reset point style
    (vla-SetVariable doc "PDMODE" oldPDMODE)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 14:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部