Copy link to clipboard
Copied
I am working on a very basic script that exports coordinates from Illustrator.
At the moment I am just outputing the values via $.writeln()
I was wondering if I could copy the output values to the clipboard. If so, what
am I looking for in the API ?
Thanks,
George
I can't app.copy() here Im at work with CS2… But you may be able to create a temporary text frame set then select the contents then copy… remove…
Copy link to clipboard
Copied
I can't app.copy() here Im at work with CS2… But you may be able to create a temporary text frame set then select the contents then copy… remove…
Copy link to clipboard
Copied
Thanks Mark, this workaround is fine.
Wish there was a method in the API withouth the need to add a pathText.
Copy link to clipboard
Copied
Just wondering… why did you need it on the clipboard? There is no direct way with the ESTK such as AppleScript's…
set the clipboard to "Some String"
Copy link to clipboard
Copied
For an actionscript project I will need to animate a few hundred objects to certain destinations. These destinations are given by a designer who works on the look and feel of things in Illustrator.
I would like to make it as simple as possible for the designer to adjust things visually in Illustrator, then he can get a snippet to test in Flash as well.
Thank you very much for the applescript idea!
I'll use something like:
app.system("osascript -e 'set the clipboard to \"" + code + "\"'");
Copy link to clipboard
Copied
app.system() is Bridge and Photoshop only isn't it? Not even documented in Photoshop either… Would be nice to have suite wide I have mentioned several times in the forums before now… Did someone listen and I didn't notice… If it did work you could try pbcopy & pbpaste…
Copy link to clipboard
Copied
ouch! You're right!
So, can I go from JS to Applescript and set the clipboard ?
How would I set the clipboard without using textPath ?
Copy link to clipboard
Copied
Unfortunately No… The only app in the suite that allows JS to perform AS is Indesign… With its app.doScript() you will quickly find me on a rant about a level playing field for this stuff… That's why the copy from text frame is probably still the way I would go… too many hoops to jump thru otherwise…
Copy link to clipboard
Copied
app.system() through out CS feature request form sent, who knows
Thank you very much Mark, this is very helpful.
Copy link to clipboard
Copied
Any idea what the equivalent to app.system is in illustrator? I'm trying to call an OSA script through Javascript.
Copy link to clipboard
Copied
There is an additional trouble -- 'TextFrame' has no 'select()' method or property.
myTextFrame.selected = true;
Alas. It doesn't work.
I've managed do select and copy/cut through two steps:
1. Select all objects.
2. Exclulde from the selection every item which name is not equal to name of my 'TextFrame'.
var myDoc = app.activeDocument;
var clip = myDoc.textFrames.add(); // create a temporary TextFrame
clip.contents = "aaa"; // place your text here
clip.name = "TextFrame for copy"; // any unique name for the temporary TextFrame
myDoc.selectObjectsOnActiveArtboard(); // select all objects
// the loop for deselecting all but the 'clip' with unique name
var sel = myDoc.selection;
for (i=0; i<sel.length; i++) {
if (sel.name != clip.name) sel.selected = false;
}
app.cut(); // cut temporary TextFrame to clipboard
Copy link to clipboard
Copied
With text frames, you select text ranges inside the text frames.
Copy link to clipboard
Copied
Yes, you can select and deselect text ranges, but you can not copy (app.copy()) this selection to clipboard.
var myDoc = app.activeDocument;
var clip = myDoc.textFrames.add();
clip.contents = "abc";
clip.selected = true; // it doesn't work
clip.textRange.select(); // it works...
app.copy(); // it doesn't work again
Copy link to clipboard
Copied
Indeed, it is so! Apparently when selecting through script, the cursor does not find its way inside the text frame and copy/cut complains about some gradient mesh.
But, for me 'textFrame.selected = true' does work, so if I needed to put into clipboard some text, I'd copy that text frame which has the text.
Interestingly, copying a text frame will let me paste the text contents into Notepad, and the reverse is true where pasting notepad text yields a new point text item.
Copy link to clipboard
Copied
Probably 'textFrame.selected = true' doesn't work in Illustrator CS6 only? It looks like a bug.
I've found the variant that works fine for me:
var tempObj = app.activeDocument.pathItems.add(); // create some temporary object
var myText = app.activeDocument.textFrames.add(); // create the text frame
myText.contents = 'abc';
tempObj.selected = true; // select the temporary object first -- it is important part!
myText.selected = true; // <--- suprise! now you can select the text frame just like any other object
tempObj.remove(); // delete the temporary object
app.copy(); // voilá
Surely this solution is more efficient than the loop through all objects.
Copy link to clipboard
Copied
Yea, strange - but I cannot say, I have not used CS6 since years ago.