I am very new to applescript, but need to be able to fill circles and apply pattern swatches to rectangles in Illustrator via the applescript.
Does anyone know the proper syntax for that?
I would greatly appreciate any help!
:?: [/b]
I am very new to applescript, but need to be able to fill circles and apply pattern swatches to rectangles in Illustrator via the applescript.
Does anyone know the proper syntax for that?
I would greatly appreciate any help!
:?: [/b]
Hi,
AS is hard enough that we’d want to know what the jumping off point would be for these syntax examples. What sorts of documents do you have? Are you opening them by hand or by script? Better to provide too many details than not enough. Otherwise, when I read your message I think, ‘Well, this is an open ended question. I’d better provide lots of examples and explanations and other infrastructure for understanding. But at the same time, I’ll be shooting in the dark, so I still might miss. Plus, I’m not confident at all that Yvon is going to be able to put all my effort to good use, since she’s a beginner and I don’t know what she’s doing exactly.’
Since posting the first message, I have figured out how to draw and fill circles. However I am still running into problems with the fill patterns and swatches. I have purchased several books, but they lack actual examples of syntax. So far, I have the following:
set obj to make new rectangle in mydoc with properties ¬
{bounds:{xgl, glh, glw, ygl}}
set fill color of path item 1 of document 1 to {pattern:pattern 1 of document 1}
I receive an out of memory message and Illustrator shuts down. I’m only trying to apply a very simple pattern to a relatively small rectangle.
The whole point of this script is to take data from a very large excel file and generate reports in illustrator in order to save a lot of time, as these are now being made individually.
I have programmed in several languages before, however this is my first experience with applescript. Any other language has books full of examples of syntax, but applescript has dictionaries that are very vague to beginners and do not provide any clues to actual syntax.
Thank you for your reply, it is very frustrating, since I am trying to do something pretty simple and straight foreward, but am not having much luck.
Are there any good sources of example text that you know of on the web? That would definately help.
The fill color really needs a value of class “pattern color info”, which when you look in the dictionary consists of several other properties as well as “pattern”. The problem you’re seeing stems from the fact that the defaults for some of these are, um, ill-chosen. In particular, the default for scale factor is {0, 0}, and all the matrx values are also set to 0.
The solution is to provide more sensible values:
set fill color of path item 1 of document 1 to {class:pattern color info, scale factor:{100.0, 100.0}, matrix:{class:matrix, mvalue_a:1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:1.0, mvalue_tx:0.0, mvalue_ty:0.0}, pattern:pattern 1 of document 1}
–
Shane Stanley
Thank you very much. I applied the syntax to my script and it is running very well. I do, however, have continuing questions.
I am attempting to add a symbol to the document; my code is as follows:
make new symbol item in document 1 with properties {source art:{symbol 13 of document 1}, class:symbol, scale factor:{100.0, 100.0}, position:{10, 10}}
I am missing a parameter, and so it will not compile.
Also, I would like to insert text boxes – so text will wrap where appropriate and be centered. Any suggestions on defining this box or justifying? So far I have been inserting text as follows:
set mytext to make new text art item in document 1 with properties
{contents:Plate, position:{544.326, 50}}
set size of text of text art item 1 of document 1 to 24
set font of text of text art item 1 of document 1 to “helvetica”
Other than these formatting issues, the script is nearly complete, and is successfully generating reports in Illustrator from Excel data.
Thank you again for the help with the patterns, I was getting very frustrated with that!
Any suggestions or examples are greatly appreciated!
–Yvon
I have continued to make progress, however I am still having difficulty with the properties of objects and syntax.
My final obstacle is inserting descriptions by way of area text.
Do I need to draw a rectangle to set the bounds for the text
tell application "Adobe Illustrator 10"
set obj to make new rectangle in mydoc with properties ¬
{bounds:{xgl, glh, glw, ygl}}
set fill color of path item 1 of mydoc to {class:pattern color info, scale factor:{100.0, 100.0}, matrix:{class:matrix, mvalue_a:1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:1.0, mvalue_tx:0.0, mvalue_ty:0.0}, pattern:pattern NAMELith of mydoc}
set stroke color of path item 1 of document 1 to {gray value:100}
tell mydoc
set obj to make new rectangle in mydoc with properties ¬
{bounds:{xdescr, descrh, descrw, ydescr}}
set stroke color of path item 1 of mydoc to {gray value:0}
set fill color of path item 1 of mydoc to {gray value:0}
set textObj to make new text art item in path item 1 of mydoc with properties {position:{xdescr, ydescr}, contents:{NAMELith & " " & classLith & ": " & DescLith}, kind:area text}
end tell
, or do I define a textpath first, instead of a rectangle?, or can I just set bounds in the properties of the text art item, since it’s kind is area text?
How do I structure the text art statement so that it recognizes the rectangle, textpath, or bounds?
I have tried various syntax combinations and the only error I’ve received is cannot make text.
To add complexity, the contents consist of three variables, of which the first two need to be bold.
I also need a way to tell how many lines each description is, to avoid overlap. Is there a comand for something like that, or should I try to insert the text after the already existing text?
Sorry for the long, multi-part question, but I have been all over the web, through reference books etc. I have as of yet only found examples for point text, and statements saying that you can make area text. - made some text justification headway yesterday, with the help of a Japanese website, which thankfully was partially in english!
Any help is extremely appreciated.
Yvon