Alineación del texto de una línea

AutoCAD ActiveX

 
Alineación del texto de una línea
 
 
 

Puede justificar texto de línea horizontal y verticalmente. La alineación por defecto es la izquierda. Para establecer las opciones de alineación horizontal y vertical, utilice la propiedad Alignment.

Modificación de la alineación del texto

Este ejemplo crea un objeto Text y un objeto Point. El objeto Point se establece como el punto de alineación del texto y se cambia por un cursor en cruz rojo para que esté visible. Se cambia la alineación del texto y se muestra un cuadro de mensaje para indicar que la ejecución de la macro está detenida. Esto permite ver qué ocurre al cambiar la alineación del texto.

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