我有一个简单的问题,但我找不到答案。对于我的工作,我必须制作150x200厘米的印张。在这些工作表中,设置了许多边框边框以填写工作表。然后我们将打印出来。
现在我总是从画板上的一个副本开始,设置我的剪切线,将它们分组并获得我想要的副本数量,我用ctrl + shift + Alt(和CTRL + D)手动复制它们来填充画板的宽度和长度。
现在我想知道是否有一个工具或脚本,我可以告诉插图画家,我想要100边框到边框,它自动填充我的画板与副本。
有什么想法吗?
答案 0 :(得分:0)
AI有一个丰富的对象模型。对象模型允许您手动完成所有操作,等等。可以从Adobe官方网站下载对象模型指南。
可以从支持自动化的任何编程或脚本语言访问对象模型。示例包括任何现代C语言IDE,VBA,JavaScript和许多其他。
您正在寻找的是Duplicate方法。 Duplicate方法的工作时间比复制/粘贴快。 Duplicate方法可以应用于许多AI对象,例如路径,组项,光栅图像,文本框等。
下面的VBA代码绘制图案,然后使用此图案填充图纸。您可以使用此代码作为访问AI对象模型的基本教程。只需从任何MS Office应用程序打开VBA编辑器,粘贴并运行代码即可。
祝你好运!Option Explicit
Const CM2PT As Double = 28.3465
Const DOC_W As Double = 15# ' Document width (cm)
Const DOC_H As Double = 20# ' Document height (cm)
' NB: The combination of PATTERN_W, PATTERN_H, PAD_W, PAD_H should
' conform the Netherlands flag proportions 3:2
Const PATTERN_W As Double = 3# ' Pattern width (cm)
Const PATTERN_H As Double = 2# ' Pattern height (cm)
Const PAD_W As Double = 3# ' Flag pad width (pt)
Const PAD_H As Double = 2# ' Flag pad height (pt)
Sub Test()
Dim aiApp As Object ' Illustrator.Application
Dim aiDoc As Object ' Illustrator.Document
Dim aiPath As Object ' Illustrator.PathItem
Dim srcGroup As Object ' Illustrator.GroupItem
Dim dstGroup As Object ' Illustrator.GroupItem
Dim StripeColor_1 As Object ' Illustrator.RGBColor
Dim StripeColor_2 As Object ' Illustrator.RGBColor
Dim StripeColor_3 As Object ' Illustrator.RGBColor
Dim FrameColor As Object ' Illustrator.RGBColor
Dim Stripe_L As Double ' Left of a flag stripe (pt)
Dim Stripe_T As Double ' Top of a flag stripe (pt)
Dim Stripe_H As Double ' Height of a flag stripe (pt)
Dim Stripe_W As Double ' Width of a flag stripe (pt)
Dim i As Long
Dim j As Long
'*******************************************************************************
' Init
'*******************************************************************************
On Error Resume Next
Set aiApp = CreateObject("Illustrator.Application") ' Late binding
' Set aiApp = New Illustrator.Application ' Early binding
If (Err <> 0) Then Exit Sub
Set aiDoc = aiApp.Documents.Add(1, CM2PT * DOC_W, CM2PT * DOC_H) ' 1 = AiDocumentColorSpace.aiDocumentRGBColor
If (Err <> 0) Then Exit Sub
Set StripeColor_1 = CreateObject("Illustrator.RGBColor")
Set StripeColor_2 = CreateObject("Illustrator.RGBColor")
Set StripeColor_3 = CreateObject("Illustrator.RGBColor")
Set FrameColor = CreateObject("Illustrator.RGBColor")
Set srcGroup = aiDoc.GroupItems.Add
On Error GoTo 0
'*******************************************************************************
' Draw the flag of Netherlands
'*******************************************************************************
Stripe_L = PAD_W
Stripe_T = aiDoc.Height - PAD_H
Stripe_H = (CM2PT * PATTERN_H - 2 * PAD_H) / 3
Stripe_W = CM2PT * PATTERN_W - 2 * PAD_W
' Top stripe = Bright Vermilion RGB(174, 28, 40)
StripeColor_1.Red = 174
StripeColor_1.Green = 28
StripeColor_1.Blue = 40
' Center stripe = White RGB(255, 255, 255)
StripeColor_2.Red = 255
StripeColor_2.Green = 255
StripeColor_2.Blue = 255
' Bottom stripe = Cobalt Blue RGB(33, 70, 139)
StripeColor_3.Red = 33
StripeColor_3.Green = 70
StripeColor_3.Blue = 139
' Frame color = Black
FrameColor.Red = 0
FrameColor.Green = 0
FrameColor.Blue = 0
' Top stripe
Set aiPath = aiDoc.PathItems.Rectangle(Stripe_T, Stripe_L, Stripe_W, Stripe_H)
aiPath.Filled = True
aiPath.FillColor = StripeColor_1
aiPath.Stroked = False
Call aiPath.Move(srcGroup, 1) ' 1 = AiElementPlacement.aiPlaceAtBeginning
' Center stripe
Set aiPath = aiDoc.PathItems.Rectangle(Stripe_T - Stripe_H, Stripe_L, Stripe_W, Stripe_H)
aiPath.Filled = True
aiPath.FillColor = StripeColor_2
aiPath.Stroked = False
Call aiPath.Move(srcGroup, 1) ' 1 = AiElementPlacement.aiPlaceAtBeginning
' Bottom stripe
Set aiPath = aiDoc.PathItems.Rectangle(Stripe_T - 2 * Stripe_H, Stripe_L, Stripe_W, Stripe_H)
aiPath.Filled = True
aiPath.FillColor = StripeColor_3
aiPath.Stroked = False
Call aiPath.Move(srcGroup, 1) ' 1 = AiElementPlacement.aiPlaceAtBeginning
' The cover
Set aiPath = aiDoc.PathItems.Rectangle(aiDoc.Height, 0, CM2PT * PATTERN_W, CM2PT * PATTERN_H)
aiPath.Filled = True
aiPath.FillColor = StripeColor_2
aiPath.Opacity = 50#
aiPath.Stroked = True
aiPath.StrokeColor = FrameColor
aiPath.StrokeWidth = 0.25
Call aiPath.Move(srcGroup, 1) ' 1 = AiElementPlacement.aiPlaceAtBeginning
'*******************************************************************************
' Duplicate
'*******************************************************************************
For i = 1 To DOC_H / PATTERN_H
For j = 1 To DOC_W / PATTERN_W
Set dstGroup = srcGroup.Duplicate
dstGroup.Left = PATTERN_W * CM2PT * (j - 1)
dstGroup.Top = aiDoc.Height - PATTERN_H * CM2PT * (i - 1)
Next
Next
Call srcGroup.Delete
'*******************************************************************************
' Finish
'*******************************************************************************
FINISH:
Set StripeColor_1 = Nothing
Set StripeColor_2 = Nothing
Set StripeColor_3 = Nothing
Set FrameColor = Nothing
Set aiDoc = Nothing
Set aiApp = Nothing
End Sub