TextAlignmentPoint 属性 (ActiveX)
指定文本和属性的对齐点。 支持的平台:仅限 Windows 属性值只读:不 类型:变体(双打的三元素阵列) 表示对象对齐点的 3D WCS 坐标。 言论文本:此属性将重置为 0、0、0,当属性设置为 时,此属性将变为只读。若要放置对齐方式为“left”、“fit”或“aligned”的文本,请使用该属性。AlignmentacAlignmentLeftInsertionPoint 例子VBA: 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
可视化 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)))
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-30 23:19
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.