Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all 12845 articles
Browse latest View live

Assigning ICC profile to an AI or EPS document (that has no profile)

$
0
0

Hi

 

I´m using Illustrator CS6.

 

I have some AI and EPS files without embed ICC profiles.

 

I´m trying to write a JavaScript that opens each document, assign the working ICC profile then save and close.

 

Have already done everything about opening and closing. It´s perfect.

 

The problem is the embeding ICC profile. Reading Illustrator JavaScript reference I did not find any method I could use to assign an ICC profile to the activeDocument.

 

Can you confirm it´s really not possible? (to assign an ICC profile to the opened topmost document)

 

Thank you a lot

 

Gustavo.


Startup Script for Illustrator only

$
0
0

Hi,

 

I've made a nice palette script for Illustrator CS6 on OSX 10.6.8.

I put it into HD/Library/Application\ Support/Adobe/Startup\ Scripts\ CS6/Illustrator

 

I works fine in Illustrator.

 

BUT: If I start Indesign CS6, the palette show up twice and it is not possible to close both pallettes.

 

Any hints?

 

Next question: The palette is used to have an easy access to script. If I start the scripts with the palette, the error messages of the scripts are not displayed. If I start individal script directly in Illustrator errors are displayed. What can I do?

 

Thanks for your help.

 

 

 #target illustrator;

#targetengine main;

//var pfad = "/Applications/Adobe\ Illustrator\ CS6/Presets.localized/de_DE/Skripten/"
var pfad = "/Volumes/Platte/Hilfsmittel/Skripte/"

var win = new Window('palette', 'Daniels Zauberkiste');
var tpanel = win.add ("tabbedpanel");
tpanel.alignChildren = ["fill", "fill"];
tpanel.preferredSize = [100,20];
win.margins = 0;
win.spacing = 0;
var subtab1panel = tpanel.add ("tab", undefined, "allgemein");
subtab1panel.orientation="row";
subtab1panel.alignChildren = ["fill", "fill"];


var t1group = subtab1panel.add("group");
t1group.orientation = "column";
t1group.alignChildren = ["fill", "fill"];


var btnSelect1 = t1group.add('button', undefined, 'Passer');
var scriptToLoad1 = new File(pfad+"_Passer-Montage.jsx");
var btnSelect2 = t1group.add('button', undefined, 'Prüfpasser');
var scriptToLoad2 = new File(pfad+"_Prüfpasser-Montage.jsx");
var btnSelect3 = t1group.add('button', undefined, 'Kontur+10');
var scriptToLoad3 = new File(pfad+"_Kontur+Dok+10.jsx");
var btnSelect4 = t1group.add('button', undefined, 'Kontur+20');
var scriptToLoad4 = new File(pfad+"_Kontur+Dok+20.jsx");
var btnSelect5 = t1group.add('button', undefined, 'Standardbogen Stanze');
var scriptToLoad5 = new File(pfad+"_Bogengröße.jsx");


btnSelect1.onClick = function(){
      var des = scriptToLoad1;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();  
}// end function


btnSelect2.onClick = function(){
      var des = scriptToLoad2;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send(); 
}// end function


btnSelect3.onClick = function(){
      var des = scriptToLoad3;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function


btnSelect4.onClick = function(){
      var des = scriptToLoad4;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function


btnSelect5.onClick = function(){
      var des = scriptToLoad5;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function










win.center();
win.show();

Illustrator Timestamp

$
0
0

Is it possible to create a script for Illustrator that would "timestamp" the file when edits/changes have been made?

Sub Menu GUI display only on Checkbox selection, hide when unselected.

$
0
0

Hi All,

 

Can somebody help me with the GUI stuff in the below code.

I've this code to display two menus,

Coordinates(Checkbox) with three Radio button items.

and similarly textboxes (checkbox) with two radio button items.

 

So what I would here like to do is highlight the radio buttons only when Checkbox is clicked.

Otherwise just hide them

To_forum_menu.jpg

 

 

Currently the code displays the box everytime@

// Config values






var dlg = new Window('dialog', 'Title');
dlg.frameLocation = [100,100];
dlg.size = [300,350];


dlg.intro = dlg.add('statictext', [20,10,220,30] );
dlg.intro.text = '"Select 1 (or) more items"';






var CoordinatesCheckBox = dlg.add ("checkbox", [20,90,150,110], "Coordinates");


var centerCoordinateRB = dlg.add ("radiobutton",[40,110,200,130] , " Top ");
var midCenterCoordinateRB = dlg.add ("radiobutton",[40,130,200,150] , " Middle ");
var leftCoordinateRB = dlg.add ("radiobutton", [40,150,200,170], " Bottom ");




var textAreasCheckBox = dlg.add ("checkbox", [20,170,150,190], " Text");
var horizontalSwipeRB = dlg.add ("radiobutton", [40,190,150,210], " Horizontal ");
var verticalSwipeRB = dlg.add ("radiobutton", [40,210,150,230], " Vertical ");


dlg.GenerateButton = dlg.add('button', [20,270,150,300], 'Generate', 'CenterCoord');




// Button Event Handler
function clickHandler(e)
{
    generateDimensions();
}
dlg.GenerateButton.onClick = clickHandler;                                            
dlg.GenerateButton.addEventListener('mousedown', clickHandler);






dlg.show();






var bCoordinatesCheckBox = false;
CoordinatesCheckBox.onClick = function ()
{
    if (CoordinatesCheckBox.value == true)    {          bCoordinatesCheckBox = true;          clearCheckBoxes(eAssetCoordinatesChecked);     }     else         bCoordinatesCheckBox = false;
}


var btextAreasCheckBox = false;
textAreasCheckBox.onClick = function ()
{
    if (textAreasCheckBox.value == true)    {          btextAreasCheckBox = true;          clearCheckBoxes(eSwipeAreasChecked);     }    else          btextAreasCheckBox = false;


}


var bHorizontalSwipe = false;
horizontalSwipeRB.onClick = function ()
{
    if (horizontalSwipeRB.value == true)         bHorizontalSwipe = true;
}


var bVerticalSwipe = false;
verticalSwipeRB.onClick = function ()
{
    if (verticalSwipeRB.value == true)         bVerticalSwipe = true;
}




var bleftCoordinateRB = false;
leftCoordinateRB.onClick = function ()
{
    if (leftCoordinateRB.value == true)         bleftCoordinateRB = true;
}


var bmidCenterCoordinateRB= false;
midCenterCoordinateRB.onClick = function ()
{
    if (midCenterCoordinateRB.value == true)         bmidCenterCoordinateRB = true;
}




var bcenterCoordinateRB = false;
centerCoordinateRB.onClick = function ()
{
    if (centerCoordinateRB.value == true)         bcenterCoordinateRB = true;
} 

Illustrator Macros/Scripting

$
0
0
Hey guys is it possible to create macros in illustrator, or how would this be achieved via the scripting.

Basically i have a c# application that contains alot of pictureboxes all with images in them. i want to be able to right click an image and select vectorise. Which will send the image to illustrator live trace the image, resize it, then copy the resulting image back into my c# app.

How would this be best done

thanks
r

Avoiding "PDF Modification Detected" blocking dialog

$
0
0

Hello,

 

I am working on an Illustrator script opens an AI or PDF file, extracts some information, then converts it to a JPEG.  It is designed to run unattended in batch mode, and sometimes is used to process PDF files which were not created by us, but were submitted from the Internet.  The script is working properly for most documents.

 

However, we sometimes end up with PDF files that cause this warning dialog to pop up:

 

PDF Modification Detected
This document has been modified outside of Adobe Illustrator.
How do you want to proceed?

[ ] Discard changes, preserving Illustrator editing capabilities
[ ] Keep changes, reducing Illustrator editing capabilities

Cancel; OK

 

The dialog is blocking, and so prevents our unattended script from running until a user walks to the console and presses "OK" or "Cancel".

 

The script is in JavaScript, and contains this line, which I thought would prevent this sort of dialog from coming up:

 

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

 

Does anybody have suggestions for avoiding this dialog?  I would prefer for it to just select "OK" automatically, but even failing would be much better than blocking.

 

Alternatively, any suggestions for detecting documents that are likely to trigger this warning beforehand?

 

Thanks!

 

-----Scott.

Exporting Adobe Illustrator XMP Data

$
0
0

Hello,

 

My biggest problem is that doesn't know how to write script. Can anyone kind enough to enlighten me with a ExtendScript to export Adobe illustrator XMP data into a xml file please?


Regards,

Jeno

Cutting a circle

$
0
0

Hi all,

 

I need to make shapes like this based on a value for graph purposes - usually I would just create a cutting shape based on trig (this shape representing around 60%) and subtract it from the path - I have about 30 graphs to do and I need to base it on a variable, and I want to use script - I'm sure there must be a better way, and I'm hoping you guys have the answer.

 

Thanks in advance

 

Dave

cut.png


app.activeDocument.activeDataset.name

$
0
0

Hi,

 

I've set up an action that I'm using to batch my process. I iterate through the dataSets[i] that have unique names. I am trying to determine the name of the current index of the datasets[i]. I am able to read the name like this:

 

alert(app.activeDocument.dataSets[0].name);// this only reads the name of the dataset at [0] for every iteration. myset_0,myset_0,myset_0,myset_0,myset_0,myset_0,myset_0...

 

The problem is that I call this during the batch process using the dataset. I can't remove the dataset at zero, because it will change the length and mess up the batch.

 

 

I would like to do it like this:

 

alert(app.activeDocument.activeDataset.name);//myset_0,myset_1,myset_2,myset_3,myset_4,mys et_5,myset_6...

 

but I'm getting undefined.

 

I'm not sure what is wrong with the syntax of this:

 

app.activeDocument.activeDataset.name

 

thanks,

Aubrey

Batch convert EPS/AI to PNG using Javascript

$
0
0
Hi,

I have lots of eps and ai files which I would like to convert to PNG format. The reason for doing this is to make it easier to find the image that I want instead of opening it one by one. I know Photoshop can do the conversion but limited to JPG, PSD and TIFF only. The filesize also will be so huge and the image quality is not sharp.

One of the preset scripts for Adobe CS3 is SaveDocsAsPDF. I tried using this and then convert the PDF to PNG using Acrobat. I would required too much time to do it. I think there might be a better way to achieve the same result.

I am not a programmer and cant figure out how to tweak the SaveDocsAsPDF script and become SaveDocsAsPNG script.

It would be great if I can just select the folder and all the conversion will be done in the backgroud.

Anyone can help me?

Thanks

apply clipping mask to every top level group in document

$
0
0

Example file: https://drive.google.com/file/d/0BzEoJSYDhH_WcXhIalFRTk9qOGc/view?usp=sharing

 

We can assume:

• Grouped art on setups with a named die line.

• All groups exist on 'Layer 1'

 

I am looping through the groups and working with groups who's parent is 'layer'. I was looping through all the groups in the document, but when I created the clipping mask it creates a new group and screws up my loop. I am now looping only through the groups on 'Layer 1' and moving them to a new layer before doing the clipping mask. My script is breaking after the group has successfully moved to the new layer. I have a bunch of alerts in it for debugging.

 

#target Illustrator


var idocX = app.activeDocument;
var li = idocX.layers;


function meetTheParents(PageItem){
  if (PageItem.parent.typename = "Layer"){  return "Layer";  } else if (PageItem.parent.typename = "GroupItem"){  return "Group";  }
}

function isLayerFree(layer){
  if (layer.locked == false && layer.visible == true){  var gpa = layer.parent;  isLayerFree(gpa);  return true  } else {  return false  }
}


var trLyr = li.add();
trLyr.name = "TRASH";
var l1 = li.getByName('Layer 1');
for (j = l1.groupItems.length -1; j >= 0; j--) {  app.executeMenuCommand ('deselectall');  var iGroup = l1.groupItems[j];  if (iGroup.hidden==false && iGroup.locked==false) {  if (meetTheParents(iGroup) == "Layer"){  if (isLayerFree(iGroup.parent)){  iGroup.move(trLyr, ElementPlacement.PLACEATBEGINNING);  // set die variable to die in current selection  alert ("Group " + j + " moved to trash layer");  alert ("trash layer path items length = " + trLyr.pathItems.length); // I'm getting '0' here even though I just moved items into it.  var die = trLyr.pathItems.getByName('proofLine'); // script breaks here  alert ("Die identified for this group");  die.move(trLyr, ElementPlacement.PLACEATBEGINNING);  for (a = 0; a < trLyr.pageItems.length; a++){  var thing = trLyr.pageItems[a];  if (thing.hidden==false && thing.locked==false){  thing.selected = true;  }  }  var sel = idocX.selection; // get selection  alert (sel.length + " items in current selection.");  // make clipped group of die with art inside  if (sel.length==2) {// continue only if 2 objects are selected  var igroup = idocX.groupItems.add(); // add a group that will be the clipping mask group  var imask = sel[0]; // the mask is the object on top  var ipath = sel[1]; // the "drawn object" is at the bottom  var idup = imask.duplicate(); // duplicate the mask, to later get the fill and stroke to apply to the clipping path  ipath.move (igroup, ElementPlacement.PLACEATBEGINNING); // add both path to the group  imask.move (igroup, ElementPlacement.PLACEATBEGINNING);  imask.clipping = true; // make the mask the clipping path  igroup.clipped = true; // clip the everything in the group to the clipping mask  if (idup.filled == true){  imask.fillColor = idup.fillColor; // add fill color, same as the dup  }  imask.stroked = true; // stroke the mask  imask.strokeWidth = idup.strokeWidth; // add stroke width, same as the dup  imask.strokeColor = idup.strokeColor; // add stroke color, seme as the dup  idup.remove(); // remove the duplicate  }else { // show this message if other than 2 objects are selected  alert("Select both, the Mask and the object that needs to be 'inside'.\rThe Mask needs to be the top most object.");  }  app.executeMenuCommand ('deselectall');  igroup.move (l1, ElementPlacement.PLACEATBEGINNING);  }  }  }
}
trLyr.remove();

 

Inside my larger script it breaks silently, in this example script it gives me a "no such element". There should be such an element, I just put it there. After the script closes, the group has been moved, meaning that the named path is right where it should be.

Precise copy and move selected Objects using JavaScript to control Illustator CS6

$
0
0

Sorry - I've asked this question before, but in the wrong forum!

 

I want to select everything in my document and copy it a precise

distance across the page (x number of times using a for loop)

and then everything down the page (y number of times, ditto)

 

for example:-

 

var stepac=58 //distance across

var stepback=349.25/6 //distance down

stepac=stepac*2.83463717

stepback=stepback*2.83463717

 

The measurements are in millimetres, then converted to points

for use with the correct syntax when I can discover what it is.

 

Any help given will be most gratefully received.

XMLHttpRequest equivalent in Illustrator CS6 JavaScript?

$
0
0

Is there any way to make an XMLHttpRequest equivalent in Illustrator CS6 JavaScript?

 

I'd love to be able to have an Illustrator script make use of returned JSON. Is it possible? For instance, in plain old HTML and vanilla JavaScript, Id' do this:

 

<!DOCTYPE html><html lang="en-US">    <head>        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title>AJAX</title>        <script type="text/javascript">            var xmlHttp = null;            xmlHttp     = new XMLHttpRequest();            xmlHttp.open( "GET", "http://example.com", false );            xmlHttp.send( null );            var data    = JSON.parse(xmlHttp.responseText);            alert(data.string);        </script>    </head>    <body style="background-color:#e5eecc;">        <div>Trying to grab some tasty JSON data.</div>    </body></html>

 

However, when I try a similar thing in a Illustrator script, I get "Error 22: XMLHttpRequest does not have a constructor."

 

I have full control over the server the JSON would be coming from if that helps.

Add image link filename to each artboard

$
0
0

Hello everyone!

 

I have a document with several artboards. In each artboard is a different linked image. Is there a way to add the linked filename to the bottom of each artboard? Thank you!

JS - Center Selection to Artboard / New Document with certain Artboard size

$
0
0

TL;DR:

how do I center my current selection to the artboard?

just like hitting the "horizontal align-center" and "vertical align-center" buttons.

 

 

Hi,

 

I've been searching for the last two hours and before my head hits the keyboard I wanted to ask you for help.

 

What I'm struggling with:

in my init function i create a new document and then copy all layers from the previous document step by step to the new document and then save it as SVG.

 

// Init

(function(){

          destination = Folder.selectDialog('Select folder for SVG files.', docPath);

          if (!destination){return;}

          holderDoc = app.documents.add();

          stepThroughAndExportLayers(docRef.layers);

}());

 

my problem is that holderDoc = app.documents.add(); always creates a document that is not the same size as my initial document where the layers get copied from.

 

so I want the exact same artboard size as in my initial document.

I'm fine with either doing it as fixed values or taking directly the values of the inital doc.

 

i tried this in the segment where I create the new document:

 

// Init

(function(){

  destination = Folder.selectDialog('Select folder for SVG files.', docPath);

  if (!destination){return;}

  holderDoc = app.documents.add();

  holderDoc.artboards[0].artboardRect = [0,0,128,128];

  stepThroughAndExportLayers(docRef.layers);

}());

 

and get this error message:

"Error 1200: an Illustrator error occured: 1346458189 ('PARM')

Line: 83

-> holderDoc.artboards[0].artboardRect = [0,0,128,128];"

 

which from what I've read on the web means that illustrator doesnt know what document to pick. but i have called it directly. so what could be the issue?

 

to clearify: I do not want to fit the artboard to the images/layer. the artboard should always have a certain size. (for me 128px by 128px)

 

I would highly appreciate you helping me with either fixing my approach or propose a completely new one.

Thanks so much in advance.

 

// edit: workaround


(function(){

          destination = Folder.selectDialog('Select folder for SVG files.', docPath);

          if (!destination){return;}

          var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];

          var ABRect = activeArtboard.artboardRect;

          holderDoc = app.documents.add();

          holderDoc.artboards.add(ABRect);

          holderDoc.artboards.remove(0);

          holderDoc.artboards.setActiveArtboardIndex(0);

          //stepThroughAndExportLayers(docRef.layers);

}());

 

i now added a new artboard to the new document with the same size as the artboard on the initial document.

i remove the predefined artboard on the new doc and set the new artboard as active.

BUT!

the artboard is now not centered into the window. which lets illustrator place my image with ctrl+c -> ctrl+v somewhere outside the artboard.

 

i now need to align my selection to the center of the artboard. but i cant find any reference on how to center a selection to the artboard.


TRY CATCH not working

$
0
0

Hi All,

 

I am trying to add spot color in illustrator using javascript, TRY CATCH is not woking, it is adding again and again same color value with name of "spot color 1" and "spot color 2" ...

can any one help for this

 

 

try {

var myDoc = app.activeDocument;

var spotName = "FINISHING";

var spot = myDoc.spots.add();

 

// Create CMYKColor

var cmykColor = new CMYKColor();

cmykColor.cyan = 0;

cmykColor.magenta = 100;

cmykColor.yellow = 0;

cmykColor.black = 0;

 

// Create Spot

spot.color = cmykColor;

spot.colorType = ColorModel.SPOT;

spot.name = spotName;

} catch (e){}

 

 

Thanks in advance

simon

Save file with script (skip warning 'modified outside Illustrator')

$
0
0

Hi All,

 

We all know that command:

 

app.activeDocument.save();

 

saves the document skipping all the dialogs and even alert that is popping out every time when you manually saving your file on a server:

Screen Shot 2015-04-04 at 11.03.58.png

 

My issue is that I am working on PDF files (with preserved Illustrator editing capabilities) almost all the time rather than .ai files, and everytime I use

 

app.activeDocument.save();

 

The .ai file is created.

 

My question is if it's possible to save PDF that you're working on same as you would manually 'Save' from the menu context, ommiting that annoying dialog about modified file?

 

Regards

Peter

How to log the ExtendScript Tool Kit console prints to a Text File

$
0
0

Hi Chaps,

 

I want to put prints in my whole Script and take the logs of the script.

To do this I need to log the entire console output to a Text file.


Can somebody please tell me how to write the console output to a log file?

How to script Illustrator to insert filename in to textpath?

$
0
0
Hello everybody!

I'm new to the scripting technology, and i wonder if its possible to create a java or apple script to do the following:

We are forced to name our thousands of illu-files on a specific way, that's ok, but: we have to insert the filename as text in to the illustrator-file, so that we can find the file through a hardcopy.

We are doing this manualy and this goes often wrong, so we have to reopen the file, change the text and save and print it again.

Can anybody give me a hint or even better show me a piece of code how to insert the filename of the actual illustrator-file in the active cursor-position.

My thanks!

Regards
Gregor

How to reflect in script?

$
0
0
Hi,

I want the equivalent of choosing Object > Transform > Reflect, across the Vertical axis. How would I do this with JavaScript?

Thanks,

Max
Viewing all 12845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>