Alignment 属性 (ActiveX)
指定属性、属性参照或文本的垂直和水平对齐方式。 支持的平台:仅限 Windows 属性值只读:不 类型:枚举acAlignment
言论对齐的文本使用属性来定位文本。acAlignmentLeftInsertionPoint 与 和 属性对齐或同时使用 和 属性来定位文本的文本。acAlignmentAlignedacAlignmentFitInsertionPointTextAlignmentPoint 与任何其他位置对齐的文本使用该属性来定位文本。TextAlignmentPoint ![]() 例子VBA: 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
可视化 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)
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-31 06:41
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.