您可以水平和垂直对齐行文本。左对齐是默认设置。若要设置水平和垂直对齐选项,请使用该属性。Alignment 重新对齐文本此示例创建一个对象和一个对象。对象设置为文本对齐点,并更改为红色十字准线,以便可见。更改文本对齐方式并显示一个消息框,以便停止宏执行。这使您可以查看更改文本对齐方式的影响。TextPointPoint Sub Ch4_TextAlignment() Dim textObj As AcadText Dim textString As String Dim insertionPoint(0 To 2) As Double Dim height As Double ' Define the new 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) ' Create a point over the text alignment point, ' so we can better visualize the alignment process Dim pointObj As AcadPoint Dim alignmentPoint(0 To 2) As Double alignmentPoint(0) = 3 alignmentPoint(1) = 3 alignmentPoint(2) = 0 Set pointObj = ThisDrawing.ModelSpace.AddPoint(alignmentPoint) pointObj.Color = acRed ' Set the point style to crosshair ThisDrawing.SetVariable "PDMODE", 2 ' Align the text to the Left textObj.Alignment = acAlignmentLeft ThisDrawing.Regen acActiveViewport MsgBox "The Text object is now aligned left" ' Align the text to the Center textObj.Alignment = acAlignmentCenter ' Align the text to the point (necessary for ' all but left aligned text.) textObj.TextAlignmentPoint = alignmentPoint ThisDrawing.Regen acActiveViewport MsgBox "The Text object is now centered" ' Align the text to the Right textObj.Alignment = acAlignmentRight ThisDrawing.Regen acActiveViewport MsgBox "The Text object is now aligned right" End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:32
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.