Adobe Illustrator Script情報 Version 9.0.2、10
back

PathText の VB の例 (vb)
TextType TextArtItems には、3種類の Text があります。

左図において上から順に、PointText, AreaText, PathText です。

これを VB から指定するには、

TextArt.Kind = aiPointText  PointText の VB の例

TextArt.Kind = aiAreaText  AreaText の VB の例

TextArt.Kind = aiPathText

とします。

PathText の VB の例を示します。
Private Sub Command3_Click()

    Dim appRef As New Illustrator.Application
    Dim newTextArt As Illustrator.TextArtItem
    Dim newTextPath As Illustrator.PathItem
    Dim tRGBColor As New Illustrator.RGBColor
    Dim tColor As New Illustrator.Color
    Dim x As Single, y As Single, dWidth As Single, dHeight As Single
        
    With tRGBColor
            .Red = 255
            .Green = 0
            .Blue = 0
    End With
    tColor.RGB = tRGBColor
    
    x = 115
    y = 120
    
    Set newTextArt = appRef.ActiveDocument.TextArtItems.Add
    newTextArt.Position = Array(x, y)
    newTextArt.Contents = " パスに沿って文字を入力する"
    newTextArt.Kind = aiPathText
    With newTextArt.TextRange
            .Font = "MS-PMincho"
            .Size = 28
            .Filled = True
            .FillColor = tColor
            .Stroked = True
            .StrokeColor = tColor
    End With
        
    Set newTextPath = newTextArt.TextPath_PathItems(1)
    
    dWidth = 100
    dHeight = 130
    
    newTextPath.SetEntirePath Array(Array(x, y), _
                              Array(x + dWidth / 2, y + dHeight), _
                              Array(x + dWidth, y))
    With tRGBColor
            .Red = 0
            .Green = 0
            .Blue = 255
    End With
    tColor.RGB = tRGBColor
                              
    With newTextPath
            .Filled = False
            .Stroked = True
            .StrokeColor = tColor
            .StrokeWidth = 1
            
            With .PathPoints(1)
                 .PointType = aiCorner
                 .RightDirection = Array(x - 50, y + dHeight + 10)
                 .LeftDirection = Array(x + 50, y - dHeight - 10)
            End With
            With .PathPoints(2)
                 .PointType = aiSmooth
                 .RightDirection = Array(x + dWidth / 2, y + dHeight)
                 .LeftDirection = Array(x + dWidth / 2, y + dHeight)
            End With
            With .PathPoints(3)
                 .PointType = aiCorner
                 .LeftDirection = Array(x + dWidth + 50, y + dHeight + 10)
                 .RightDirection = Array(x + dWidth - 50, y - dHeight - 10)
            End With
    End With
    
End Sub