Does anyone know how one would go about ungrouping all groups on an active layer with JavaScript?
ungroup all groups on an active layer(JavaScript).
Move layers to new artboard
Hi everybody,
I'm trying to create a script via javascript for Illustrator.
My problem is :
I have a AI file with multiple layers, i want to create one artboard per layer, in order to export a multipage PDF ( each page contain 1 layer ).
The layers represents the differents type of print ( vernish, color, hot gold, pressure ... ) and/or color type ( Pantone, CMYK, cut, kisscut ... ).
My client want a PDF for see each type of print or color type per page.
I'm trying 2 ways :
1st solution : Create new artboards, and duplicate ( or move ) layers content on the new artboad, but the function move/duplicate don't work to move content on another artboard.
2nd solution : Create new document with the same number of layers as artboard and duplicate layer to the new artboard on the new document.
Can you help me to realize this script ?
Excuse me if my english is not good.
Tweaking the SaveDocsAsPDF script
I am looking at the SaveDocsAsPDF script. It works for our purposes except I would like it to save PDFs using a Preset we created called "SGS PDFs. (We have trouble with people in our office forgetting to choose this setting, so I thought a script might be the answer.)
I found a posting on this forum where someone wanted to save files as small as possible, and got some clues from that. So I left everything as is in the original script, except I added this first line in the function:
{var NamePreset = '[SGS PDFs]';
Then after the line:
var options = new PDFSaveOptions();
I added:
options.PDFPreset=NamePreset;
I thought this would result in a script that does the same thing I now do "manually". However, if I save my document "manually" using File/Save As/ Adobe PDF, and choosing the SGS PDFs preset (and changing nothing else), I get a 716 KB file. But if I use my script, I get a 4.9 MB file. So it appears that what I added is NOT making the script use my preset settings.
So my question is: Is there something REALLY basic missing from my script, or... In order to get a script that accomplishes everything already determined in the Preset, do I manually have to list all those settings as options?
I think I can do the latter if I need to if I just study some of the other scripts... unless there's a shortcut!
Change font in Illustrator cs4 js
I need to assign specific font to my text and it doesn't work. What am I doing wrong:
var my_OUTSIDE_TextFrame = myInstrLayer.textFrames.add(); my_OUTSIDE_TextFrame.geometricBounds = ["1.6 in", "1 in", "1.85 in", "2.75 in"]; my_OUTSIDE_TextFrame.contents = "OUTSIDE"; var myParagraph = my_OUTSIDE_TextFrame.paragraphs.item(0); try{ myParagraph.appliedFont = app.fonts.item("Myriad Pro"); } catch(e){} try{ myParagraph.fontStyle = "Bold"; } catch(e){} myParagraph.pointSize = 30;
And it's not placing it where I want it either.
Thank you very much for your help.
Yulia
Script for Selecting Open Paths in Illustrator CS6
I have created this script for selecting open paths in illustrator cs6 as the graffix plugin is not working under CS6.
Just save the following text in /Applications/Adobe Illustrator CS6/Presets/en_US/Scripts/Select Open Paths.js
if (documents.length > 0 && activeDocument.pathItems.length > 0){
var allPaths = activeDocument.pathItems;
var allPathsCount = allPaths.length;
var openPathsAreLocked = false;
var lockedOpenPaths = 0;
var locked = false;
for (var i=0; i < allPathsCount; i++){
allPaths[ i ].selected = false;
if( ! allPaths[ i ].closed){
try{
allPaths[ i ].selected = true;
} catch (e) {
openPathsAreLocked = true;
lockedOpenPaths++;
}
}
}
if (openPathsAreLocked) alert (lockedOpenPaths + " open paths are locked or hidden (or their layer is locked or hidden) and cannot be selected");
}
Any great Javascript training available online?
Hi,
I am an artist who appreciates the awesome power of Javascript, and I have come to realize how great it would be to become proficient in it.
I wanted to ask this community:
1. Can you recommend any really excellent Javascript training for beginners?
2. Can you recommend any really excellent Javascript ILLUSTRATOR training for beginners?
These resources can be free or paid for, either way.
I have used Lynda.com before and video tutorials are great. I am open to anything (Web, books, DVDs) I am even considering classes taught locally.
Suggestions?
Thanks!
Dave
ExportType.SVG "Use Artboards" option
I am trying to export layers to SVG, but I need to access the "Use Artboards" option in my ExportType.SVG options. I do not see it in the Javascript reference: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scrip ting/cs6/Illustrator-Scripting-Reference-JavaScript.pdf
Suggestions?
Thank you guys so much!
break long process in CC 2014 (Mac OS)
var win = new Window("palette", "SnpCreateProgressBar", undefined); win.pnl = win.add("panel", undefined, "Script Progress"); win.pnl.progBarLabel = win.pnl.add("statictext", undefined, "0%"); var btn = win.pnl.add ("button", undefined, "Cancel"); btn.onClick = function() { win.close(0); } win.show(); var i = 0; while(i < 200) { win.pnl.progBarLabel.text = i + "%"; $.sleep(30); win.update(); i++; // activeDocument.textFrames[0].contents = i + ""; redraw(); } alert('Done!'); win.close();
button not work
MacOS
Giveway tothe user to break the script
All Group to Ungroup Script
Download Link
http://www.cyworld.com/be2u/2801831
Feature
This Script is Can be easily ungrouping to all group items in the Document.
if find Bugs or Error, contact to me plz.
License type
Freeware
Author
Nokcha
Author Contact
Author website
Date published
june 30, 2009
Compatible product
Illustrator
Retreiving Embedded Images Information
I have a two-part question. One, I need to know why Illustrator displays embedded images at 72 dpi. Two, how can I retreive an image's correct size and/or resolution? Illustrator has the information contained somewhere, I see it being displayed in this window:
Is there a reason it returns the incorrect "Dimensions" when I ask for the width of a rasterItem?
I'm using ExtendscriptToolkit 2 to write jsx to control Illustrator CS4.
Thank you!!!
Major issues with PARM error, Adobe doesn't support JavaScript engine
I'd really appreciate it if people in the community could see if my test script produces the PARM error consistently on their installs of Illustrator and if anyone could spot some problem that might explain why the error occurs.
I'm really stuck with constant PARM errors popping up at random times through my application. After the error occurs Illustrator has to be exited and restarted otherwise it'll always error out on every JavaScript execution.
Basically, I have a big application that interfaces with Adobe by mapping buttons in an application to javascripts. Its practically unusable.due to the PARM errors.
It's something like "an Illustrator error occurred: 1346458189 ('PARM')"
I can reproduce the error with a cut down script but can't find anything wrong in what I'm doing. Adobe won't even look at the script where I can reproduce the error even on a paid support incident. According to Adobe they don't support javascript even though it's the JavaScript engine in Illustrator that's crashing.
I'm using Adobe CS5 (15.0.2 currently) in a Windows environment. Generally I'm testing in Windows 7 64-bit but Windows XP 32 bit has the same issue.
Hopefully someone can spot something I've just been doing wrong because I can't. If it's a bug then I'm out of luck since I can't even talk to anyone to report it.
I was able to create a simple example where a couple of groupItems are copied from an open document and pasted to a new document, moved to a specific group, and then removed. In reality there would be lots of formatting on the new document before the group is removed but it crashes even without doing all of that.
Here is a zip with the test script and the test document. Just open the testScript.jsx in ExtendScript Tool Kit and open testdocument.ai in Adobe Illustrator. Execute the script and it tells you how many times the test ran before it errored out. Generally this happens for me in less than 10 iterations of the test but occasionally it won't error out after 100 runs.
Here's the test script itself in case someone can spot something obvious.
#target Illustrator
function createLayout(names) {
var intResult = 1;
var docPreset = new DocumentPreset;
docPreset.units = RulerUnits.Inches;
docPreset.width = 612.0;
docPreset.height = 792.0;
docPreset.title = "Test Document";
docPreset.colorMode = DocumentColorSpace.CMYK;
var doc = app.activeDocument;
doc.selection = null;
try {
var printDoc = app.documents.addDocument(DocumentColorSpace.CMYK,docPreset);
app.activeDocument = printDoc;
var layerArt = printDoc.layers[0];
layerArt.name = 'artwork';
printDoc.activeLayer = layerArt;
var grpSource = layerArt.groupItems.add();
grpSource.name = 'source';
app.activeDocument = doc;
for(var i = 0;i < names.length;i++) {
var layerSections = doc.layers['section' + names[i]];
var grpSection = layerSections.groupItems[0];
grpSection.selected = true;
}
copy();
app.activeDocument = printDoc;
printDoc.activeLayer = layerArt;
paste();
printDoc.selection = null;
for(var i = layerArt.pageItems.length - 1; i >= 0;i--) {
var grp = layerArt.pageItems[i];
if(grp.name != 'source') {
var box = grp.pathItems['bgbox'];
box.height = box.height - 18.0;
box.position = [box.position[0],box.position[1] - 9.0];
// Omitting the move of pasted group into destination group avoids PARM error
grp.move(grpSource,ElementPlacement.PLACEATBEGINNING);
}
}
// Commenting out the remove line and setting the hidden property seems less likely to cause a PARM error
grpSource.remove();
//grpSource.hidden = true;
app.redraw();
printDoc.close(SaveOptions.DONOTSAVECHANGES);
intResult = 0;
app.activeDocument = doc;
}
catch(e) {
alert('error:\n' + e);
intResult = 1;
}
return intResult;
}
function main() {
var names = ['Left','Right'];
var counter = 0;
var result = 0;
while (counter < 100) {
var result = createLayout(names);
if (result == 1) {
alert('script failed after ' + counter + ' runs');
break;
}
counter = counter + 1;
app.redraw();
}
if(result == 0) {
alert('test produced no errors');
}
return result;
}
main();
As the comments in the script state, if I set hidden on a group instead of removing it I avoid the PARM error. If I don't move the pasted groups into the group that will be removed it doesn't crash either. However, for a test I can do this but it doesn't explain why it causes the error. I can look at rewriting parts of my many scripts to not remove any groups but I don't know that it would be effective. I tried another test where I just created objects from a new document only, moved them around, deleted them, etc. but couldn't get the PARM error to pop up just from doing that.
Dimension Illustrator CS6
Does anyone know of a script that will automatically put dimensions on rectangular shapes in Illustrator CS6?
Batch insert filename in textpath script crashes Illustrator
Hi everyone!
First off: I am not a programmer. Just playing around with code and trying to get it to work for a specific task:
Here is a script made for the purpose of inserting a text with the file name in over 600 pdf files. This is suppose to work on all files in a selected folder.
The problem: Illustrator crashes.
A first test code worked but after a few edited files Illustrator crashed, so I tried to introduce a delay after each save in order to slow down the batch process.
$.setTimeout(function () {sourceDoc.close(SaveOptions.SAVECHANGES)}, 1000);
Unfortunately I did not save the working (almost working ) first test code.
No idea what to do next. The code works if I delete this line: sourceDoc.close(SaveOptions.SAVECHANGES);
Here is the complete script:
var destFolder, sourceFolder, files, fileType, sourceDoc, layers, writeText, finLabel; // Select the source folder. sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' ); // If a valid folder is selected if ( sourceFolder != null ) { files = new Array(); fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', '*.pdf' ); // Get all files matching the pattern files = sourceFolder.getFiles( fileType ); if ( files.length > 0 ) for ( i = 0; i < files.length; i++ ) { sourceDoc = app.open(files[i]); // returns the document object layers = unlock(); writeText = getFilename(); finLabel = remText(); sourceDoc.close(SaveOptions.SAVECHANGES); //if save command line is deleted the code works WTF??? $.setTimeout(function () {sourceDoc.close(SaveOptions.SAVECHANGES)}, 1000); // still crashes using delay ... } //alert( 'Files are saved as PNG in ' + destFolder ); else { alert( 'No matching files found' ); } } function unlock() { //get the total number of layers in the active document doc = app.activeDocument; var totalLayers = doc.layers.length; //looping on layers to create one artboard per layer for ( var i = 0 ; i < totalLayers ; i++){ var currentLayer = doc.layers[i]; //We don't want to deal with hidden layers if(currentLayer.visible == false) continue; //Unlock the layer if needed currentLayer.locked = false; } } function getFilename() { // Write text var pointTextRef = app.activeDocument.textFrames.add(); pointTextRef.contents = app.activeDocument.name + "\n" + "YBS"; pointTextRef.top = 0; pointTextRef.left = 0; app.activeDocument.textFrames[0].textRange.characterAttributes.textFont=app.textFonts[31]; } function remText() { // This works for search and replace :)))))) var active_doc = app.activeDocument; var search_string = /_Template.pdf/gi; // g for global search, remove i to make a case sensitive search var replace_string = ''; var text_frames = active_doc.textFrames; if (text_frames.length > 0) { for (var i = 0 ; i < text_frames.length; i++) { var this_text_frame = text_frames[i]; var new_string = this_text_frame.contents.replace(search_string, replace_string); if (new_string != this_text_frame.contents) { this_text_frame.contents = new_string; } } } }
Any ideas about what makes Illustrator crash?
Note: The application crashes after opening the first file.
Thanks for helping out!
Split Text into Layers
I was wondering if anyone is aware of a script that is able to do the same as this photoshop one http://www.agasyanc.ru/text-splitter, I would use that one in photoshop but its not working in CS6.
I was hoping to find a script that will seperate the text into layers ready for export to After Effects to be used in Kinetic Typography pieces
thank you
moving all layers into a single layer
Hello,
I'm new in scripting and i need to make a script that moving all layers into a single layer( in Illustrator i press CTRL+A then CTRL+G in layers and works) but i need that in script
Please could somebody help me?
Thanks!
Script to Rename Artboards with Layer Names
I'm looking to create a script to batch rename a number of artboards.
- I have 100 named layers.
- I have 100 artboards.
- I would like to rename the artboards to match the layer names.
- The layers are organized in the same descending orderas the artboards (ignoring the actual artboard names*).
- The topmost artboard (1 in the list) would be renamed "newspaper", the second artboard would be renamed "typewriter", the third artboard would be renamed "books", etc.
*in the example below the artboard named "Artboard 7" is actually the 6th artboard in list.
Any help would be wonderful.
Batch combine files into one illustrator document - how to open target document?
I am making a script which will:
1) Open a folder of Illustrator files
2) Open each file in the folder (these files are called the source files)
3) Select all the contents of the source file
4) Copy the contents of the source file
5) Paste these contents into a target file as a new layer
6) Ensure the new layer has the same name as the old source file
However, I don't know how to tell Illustrator where my target file is. How can I do this?
Also, when I paste, how can I turn off paste rembers layers. (So the layers get pasted into the new layer that has the same name as the old document).
Here is my code:
// JavaScript Document
//Set up vairaibles
var destDoc, sourceDoc, sourceFolder;
// Select the source folder.
sourceFolder = Folder.selectDialog('Select the folder with Illustrator files that you want to mere into one', '~');
// If a valid folder is selected
if (sourceFolder != null) {
files = new Array();
// Get all files matching the pattern
files = sourceFolder.getFiles();
if (files.length > 0) {
// Get the destination to save the files
destDoc = document.selectDialog('Select the final saved document', '~');
for (i = 0; i < files.length; i++) {
sourceDoc = app.open(files[i]); // returns the document object
var myLayers = sourceDoc.layers; // All layers in Active Document
//Go through all layers of source document and copy artwork
for (i = 0; i < myLayers.length; i++) {
myLayers[i].hasSelectedArtwork = true;
};
with(sourceDoc) {
var count = pageItems.length;
for (var i = 0; i < count; i++) {
pageItems[i].selected = true;
}
redraw();
copy();
for (var i = 0; i < count; i++) {
pageItems[i].selected = false;
}
}
//Create a new title variable that has the title of the source document
var title = sourceDoc.name;
var title = title.substring(0, title.length - 4); //(remove extension from name)
//Close the Source Document
sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
//Open the Destination Document and create a new layer in it that is named after the title variation
var newLayer = destDoc.layers.add();
newLayer.name = title;
//Paste into this new layer
destDoc = app.paste();
}
}
else {
alert('No matching files found');
}
}
Thanks in advance for any help
Edit: Also, when pasting, how can I paste in place instead of just pasting.
Simple InDesign script -> Illustrator help
I have this script by Peter Kahrel that reverese the order of letters in InDesign.
I need an Illustrator version of it. Can anybody help?
---------------------
//ReverseText.jsx
//An InDesign Javascript that reverses the order of any selected text.
//If no text is selected with the Type tool, nothing happens.
//Written by Peter Kahrel for InDesignSecrets.com
//****************
#target indesign
if ( "TextWordLineParagraph".search ( app.selection[0].constructor.name ) < 0 )
exit();
s = app.selection[0].contents;
s = s.split("").reverse().join("");
app.selection[0].contents = s;
-------------------
Mainly using this for Arabic text in CS 3 and 4 for clients that don't have new versions - and will never buy it apparently.
Works great in InDesign. I've been putting the text in ID and then copying it into Illustrator. But it would be nice to skip that step if possible.
Thanks in advance.
Convert .ai to .doc
Hi,
Can it be possible to convert .ai file into .doc file or any tool which will do this conversion.
Thanks,
Shail
Rotating text around a circle. Have selected Warp options selected arch but text doesn't appear right?
Using Mac Pro. Have created a vector logo. All good so far. Trying to add text to a round circle shape have got as far as selecting Warp option and typed my text but despite adjusting the scale etc it doesn't seem to look right as it isn't snapping to the circle. I have tried dragging the anchors but that makes it worse!!