0
我有一個客戶希望將命令腳本編寫到Adobe Illustrator。我相信這很容易,但是當談到js 時,我基本上是使用excel電子表格上的接入點,並使用deminsions和說明。可以根據要求提供樣品和更多細節。 Bob我可以使用Javascript來繪製Adobe Illustrator嗎?
我有一個客戶希望將命令腳本編寫到Adobe Illustrator。我相信這很容易,但是當談到js 時,我基本上是使用excel電子表格上的接入點,並使用deminsions和說明。可以根據要求提供樣品和更多細節。 Bob我可以使用Javascript來繪製Adobe Illustrator嗎?
是的,您可以使用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
歡迎來到StackOverflow,Bob。這裏的人很樂意提供幫助,但需要預先詳細說明。請複習['我如何提出一個好問題?](https://stackoverflow.com/help/how-to-ask),並更新您的文章以獲取更多詳細信息。另外,考慮添加一個['Minimal,Complete和Verifiable示例'](https://stackoverflow.com/help/mcve),以顯示您的進度的當前狀態以及迄今爲止嘗試的內容。 – TheJim01
感謝您的有用建議 –
是的,您可以使用JS:http://www.adobe.com/devnet/illustrator/scripting.html –