我可以使用Javascript在Adobe Illustrator中绘图吗?

时间:2017-08-07 13:20:33

标签: node.js adobe-illustrator

我有一个想要将命令编写到Adobe Illustrator的客户端。我确信这很容易,但对于js来说,它是一个基本的 我在excel电子表格上使用访问点,带有deminsions和说明。可根据要求提供样品和更多细节。 鲍勃

1 个答案:

答案 0 :(得分:0)

是的,您可以使用js在Adobe Illustrator中进行绘制。

如果您打算从MS Excel应用程序中进行绘制,则更可取的是VBA。

下面的代码是用VBA写的,用于绘制Lemniscate。你可以用它作为例子:

Option Explicit
Option Base 0

Private ai_Doc As Illustrator.Document

Private Function Get_Lemniscate(ByVal Point_Count As Long) As Variant
Const PI As Double = 3.14159265358979
Dim t As Double
Dim t3 As Double
Dim t4 As Double
Dim i As Long
Dim ret As Variant

    ReDim ret(Point_Count)
    For i = LBound(ret) To UBound(ret)
        t = Math.Tan(PI * ((i / Point_Count) - 0.5))
        t3 = t * t * t
        t4 = t * t3
        ret(i) = Array( _
            500 + 300 * (t + t3) / (1 + t4), _
            300 + 300 * (t - t3) / (1 + t4))
    Next
    Get_Lemniscate = ret
End Function

Private Function Get_AI_Document() As Illustrator.Document
    With New Illustrator.Application
        ' It may be necessary to make AI visible here - it is a small trick 
        If (.Documents.Count = 0) Then
            .Documents.Add
        End If
        Set Get_AI_Document = .ActiveDocument
    End With
End Function

Private Sub Draw_AI_Path(ByRef Point_Array As Variant)
Dim New_Path As Illustrator.PathItem
    Set New_Path = ai_Doc.PathItems.Add
    New_Path.SetEntirePath Point_Array
    ' Do some other stuff (colors, line stroke etc)
End Sub


Sub Test()
    Set ai_Doc = Get_AI_Document
    Draw_AI_Path Get_Lemniscate(6000)
End Sub