Adobe Illustrator Script情報 Version 9.0.2、10
back

図形の作成 (vb)
TextType 図形は、PathItem のオブジェクトです。

左図において上から順に、長方形, 楕円, 角丸長方形, 三角形 です。

これを作成するには、

三角形は、pathItem.SetEntirePath Array(Array(),,)

長方形は、pathItems.Rectangle(top, left, width, height)

角丸長方形は、pathItems.Rectangle(top, left, width, height, x角丸, y角丸)

楕円は、pathItems.Ellipse(top, left, width, height)

を使用します。

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

Dim appRef As New Illustrator.Application
Dim frontDocument As Illustrator.Document
Dim lnColor As New Illustrator.Color
Dim lnRGBColor As New Illustrator.RGBColor
Dim linePath As Illustrator.PathItem
Dim x As Single, y As Single

Set frontDocument = appRef.Documents.Add(aiDocumentRGBColor, 600, 800)
             
    With lnRGBColor
            .Red = 0
            .Green = 0
            .Blue = 255
    End With
    lnColor.RGB = lnRGBColor

' 三角形の作成

Set linePath = frontDocument.ActiveLayer.PathItems.Add
    x = 70
    y = 50
    linePath.SetEntirePath Array(Array(x, y), _
                                Array(x + 80, y + 160), _
                                Array(x + 160, y))
   
    linePath.Closed = True
    linePath.Stroked = True
    linePath.StrokeWidth = 4
    linePath.StrokeColor = lnColor
    linePath.Filled = False
    linePath.StrokeJoin = aiRoundEndJoin
    
Dim pathItemsRef As Illustrator.PathItems
Dim rectPath As Illustrator.PathItem
Dim ellipsePath As Illustrator.PathItem
Dim roundedRectanglePath As Illustrator.PathItem

Set pathItemsRef = frontDocument.ActiveLayer.PathItems

' 長方形の作成
x = 50
Set rectPath = pathItemsRef.Rectangle(700, x, 200, 100)  'top left width height
    rectPath.StrokeWidth = 4
    rectPath.StrokeColor = lnColor
    
' 楕円の作成

Set ellipsePath = pathItemsRef.Ellipse(550, x, 200, 150) 'top left width height
    ellipsePath.StrokeWidth = 4
    ellipsePath.StrokeColor = lnColor
    
' 角丸長方形の作成

Set roundedRectanglePath = pathItemsRef.RoundedRectangle(350, x, 200, 100, 30, 30)
    roundedRectanglePath.StrokeWidth = 4
    roundedRectanglePath.StrokeColor = lnColor
End Sub