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

Match textFrame ignoring carriage return

$
0
0

Open this file...

Document.ai - Google Drivehttps://drive.google.com/open?id=0B4ebfmBRxh3ATXBMbTUySmtpVWs

Then open this file so it is the active document...

Table.ai - Google Drive

 

I am running a script on the table I have pasted in from an Excel document. I am storing all of the names in an array.

Then it closes the table document and then searches document for matches.

The problem I am running into is that the table document is all a single line text frame and the document has text frames with carriage returns in them.

 

Here is my current code (which includes some clean up functions for odd spaces and such)....

#target illustrator
var doc = app.activeDocument;
var allText = doc.textFrames;
var componentName = [];
var theContents;


// Remove spaces that are before, after, or double
function myTrim(x) {
    return x.replace(/^\s+|\s+$/gm, '');
}


function removeDoubleSpaces() {
    var searchString = /  /g;    var replaceString = " ";    for (var i = 0; i < allText.length; i++) {        var thisTextFrame = allText[i];        var newString = thisTextFrame.contents.replace(searchString, replaceString);        if (newString != thisTextFrame.contents) {            thisTextFrame.contents = newString;        }    }
}


for (i = 0; i < allText.length; i++) {    theContents = allText[i].contents;    theContents = myTrim(theContents);    allText[i].contents = theContents;
}


removeDoubleSpaces();


// Read table data
for (var i = allText.length - 1; i >= 0; i--) {    //alert(allText[i].contents);       componentName.push(allText[i].contents);
}
//alert(componentName.length);


alert("Your component table has been successfully scanned!");
doc.close(SaveOptions.DONOTSAVECHANGES);


// Format text on Hypertext layer to read (#) Component Name
var doc = app.activeDocument;
var allText = doc.textFrames;


for (i = 0; i < allText.length; i++) {    theContents = allText[i].contents;    theContents = myTrim(theContents);    allText[i].contents = theContents;
}


removeDoubleSpaces();


var calloutStartNumber = prompt("Start with callout number...", "1", "Callout Number");




var hyperLayer = doc.layers.getByName("Hypertext");
for (var i = 0; i < componentName.length; i++) {    //alert(componentName.length);    for (var z = 0; z < allText.length; z++) {        //alert(allText.length);        if (componentName[i] == allText[z]) {            alert(componentName[i] + "  " + allText[z]);            allText[z].contents = "(" + (calloutStartNumber) + ") " + allText[z].contents;            calloutStartNumber++;        }    }
}


alert("Your components have been numbered!");

 

My desired output is Accumulator Gp - Hydraulic (Charged) is number 1 and then each item after that on the table (that is in alphabetical order) will be numbered sequentially on the document. I don't want the script to change the text box or get rid of the carriage returns....just insert the sequential number in front of it like this....


scripting with cc libraries ?

$
0
0

I've written some scripts to place objects in illustrator or photoshop files, from a source folder on my computer.

Can I upload the files in the souce folder to a CC Library, and read the data from the CC library?

 

Has this ever been done ?

Does anyone have any examples ?

 

Thanks ,

 

Mike

How to divide all textFrames in one-character-per-textFrame?

$
0
0

Hello:

 

How to divide all textFrames in one-character-per-textFrame?

 

Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".

 

Help, please.

"File/Folder Expected" Error

$
0
0

I cannot seem to debug an error I am getting from an Applescript that is adapted from the business card template that ships with Illustrator. Specifically, at the line "updatedatasetiofdocumentcurrentDoc" I am getting an error "File/Folder expected." I am happy to post the entire script but, before doing so, does anyone see anything obviously wrong with the below which may be causing this error?

 

Thank you in advance for any assistance:

 

 

  tellapplication "Adobe Illustrator"

  activate

  setmysetcounttomyindex - 1

  repeatwithifrom 1 tomysetcount

  import variablesdocumentcurrentDocfromaliasXMLfilePath

  setpathTexttoitemioffilePaths

  updatedatasetiofdocumentcurrentDoc

  setmynewfiletoexportFolder& "CaseNo" & i& "-productsource.pdf" asstring

  setmyfiletofile pathofdocumentcurrentDoc

  savedocumentcurrentDocinfilemynewfileaspdf

  closedocument 1 savingno

  openmyfile

  endrepeat

  endtell

  endif

endbatchExport

Script to convert all "Book Color" swatches to CMYK?

$
0
0

Hi all,

 

Trying to help speed up the work flow for a specific task at work. We use Pantone colors as a reference point for color, but we have to change the "Color Mode" from "Book Color" to "CMYK" for printing. I'm hoping it's possible to write a script to do this automatically for all Pantone swatches in an Illustrator document.

 

For clarity:

Untitled-1.jpg

 

This is all we need to do. It'd just be easier if we could click a script and it happens to all the Pantone swatches at once!

 

Thanks!

Shortcut for js script with CS4 ?

$
0
0

hi all,

with my old version of illustrator (CS), i might affect a shortcut to a specific scipt .

Now i have CS4 version, and i  don't find similar possibility.

 

how can affect in this new version ?

 

Thanks for futur answer.

Anyone know of a script to convert layers to artboards.

$
0
0

I don't suppose any one could point me in the direction of a script which would convert the layers in a document to artboards? At present I have a lot of documents with a couple of hundred layers on each of them, but I've decided to change the way that I organise my workflow and started using artboards instead. I don't really have the time to spend moving them individually from a layer over on to an artboard as there are a lot.

 

Any help or information would be greatly appreciated.

 

Many Thanks,

 

K

Looking for solution to read/write Excel data...

$
0
0

   I've been using CSV to import excel data into AI - but I need to be able to import and export the excel data directly, without using ActiveX, direct reads and writes to the XLS file.  This is because CSV loses the formatting and I need to retain that.  Does anyone know of a third party javascript library for working with excel files?

 

   I've also thought of using Excel XML instead of the typical excel format as this will retain the formatting.  However, I know nothing about XML so if there is likewise an easy way to read/write excel XML files or a library somewhere for this, please let me know.


Illustator - select pathItems based on fill color

$
0
0

I am seeking a vbscript to select all pathItems based on its fillcolor.  Here's what I have but obviously wrong but I think I am on the right "path", ha!  I can't figure out how to say "if the pathitems fill color match my fillcolor, then select it and move on to the next"

 

Here's what I have:

 

Set FSO = CreateObject("Scripting.FileSystemObject")

Set App = CreateObject("Illustrator.Application")

Set SourceFolder = FSO.GetFolder("C:\SOCAL\Section_31\LandCover")

Set FillColor = CreateObject("Illustrator.RGBColor")

     FillColor.Red = 28

     FillColor.Green = 99

     FillColor.Blue = 48

 

If (App.Documents.Count > 0) Then

        Set DocPathItems = App.ActiveDocument.PathItems

        If (DocPathItems.Count > 0) Then

            For Each CurrentPath in DocPathItems

               If CurrentPath.PathItems = FillColor Then

                    CurrentPath.Selected = True

              Else

              End If

          Next

       End If

End If

How to find find color x, replace with color y?

$
0
0

Trying to figure out why this isn't working. I want to find pathItems that have a specific CMYK color and replace it with a new CMYK color.

I discovered that I should round my CMYK values, but it's still not working. Any ideas?

 

// Define colors


var targetBlue = new CMYKColor();
targetBlue.cyan = 49;
targetBlue.magenta = 25;
targetBlue.yellow = 0;
targetBlue.black = 0;


var dmnRed = new CMYKColor();
dmnRed.cyan = 0;
dmnRed.magenta = 80;
dmnRed.yellow = 80;
dmnRed.black = 0;


// Set variable for path items on active document
var docRef = app.activeDocument;


var fillRef = docRef.pathItems;


//Loop through each item and check if its fill color is targetBlue.
// If it is, change the color to dmnRed


for ( var i = 0; i < fillRef.length; i++) {       fillRef[i].fillColor.cyan = Math.floor(fillRef[i].fillColor.cyan);    fillRef[i].fillColor.magenta = Math.floor(fillRef[i].fillColor.magenta);    fillRef[i].fillColor.yellow = Math.floor(fillRef[i].fillColor.yellow);    fillRef[i].fillColor.black = Math.floor(fillRef[i].fillColor.black);              if (fillRef[i].fillColor == targetBlue) {               fillRef[i].selected = true;               fillRef[i].filled = true;               fillRef[i].fillColor = dmnRed;            }        else {               $.writeln("Item " + i + " isn't targetBlue");            }    }

Illustrator CC Book Color vs Spot Color PANTONE+

$
0
0

Hi! Here's a question about a little detail regarding PANTONE+ spot colors.
I've got a script that makes PANTONE+ colors inside a document using the available scripting methods, which produce a spot color with the desired Lab color values, but when double-clicking and bringing up the swatch dialog it does not default to the grayed-out "Book Color" option in the Color Mode dropdown.

However, it does have the Book Color option in that dropdown and if it's selected and applied, the next time this swatch is double-clicked and dialog appears, the proper Book Color mode is selected and appropriate fields are grayed out.

 

My question is: considering the functions of spot colors in Illustrator, ink plating and appearance and anything else, does my script-made swatch bear any effect on the document that would make it in any way different than a regular document where the Book Color is shown as default in the swatch options dialog?

 

In Mordy Golding's explanation of Book Color mode for Pre-CS6 versions, he states that Book Colors came with hidden information which displays PANTONE-listed Lab values which relate to the Pre-CS6 CMYK-based PANTONE swatches. Now that we have PANTONE+, and Lab is the default base for the book swatches, I wonder if there is any other property that may not be considered by some function of the application if the swatch has the correct name and Lab values while not having the Book Color mode explicitly selected.

Also, if there's an undocumented property for setting the other Color Modes which can appear in this dropdown, that would also be useful information. Our current available options for SpotColorKind are just SPOTCMYK, SPOTLAB and SPOTRGB
Screen Shot 2015-10-04 at 6.57.46 PM.png

Lab-VS-Book.png

Change RGB color to CMYK color via Javascript

$
0
0
Hi

I like to convert a document for rgb into cmyk mode via Javascript.

- The document is opened manually
Script:
- Selects all items with a defined RGB color (background or text color)
- Replace the RGB color (background or text) with a defined CMYK color

I can do that with an action, but I have to have a Javascript.

- Can I do that?
- How can I do that?
- Classes?
- Sample?

Thanks for the support
Hans

Convert .ai to .doc

$
0
0

Hi,

 

Can it be possible to convert .ai file into .doc file or any tool which will do this conversion.

 

Thanks,

Shail

Can you hide a layers using scripting?

$
0
0

I have a very complex graphic with many elements and I would like to find a way to hide layers based on a list.  In the documentation that there is a way to tell if a layer is hidden, but didn't see anything about a way to actually to control the hide/unhide property.  Is this possible?

 

Thanks!

Select by (spot) color, remove certain spot color

$
0
0

Hi,

 

I want to remove a certain object with a specific spot color from my document. Is it possible to select it by script?

 

Select by Spot Color? Convert certain spot color to CMYK Color?

 

Thanks!

 

Christoph


Batch replace color without using swatch as source

$
0
0

I've searched these forums and the rest of the web trying to find a method to do this... Actions don't cut it (if Actions were able to record the "replace color" dialoge it would be fine) so I've turned to scripts, but I have almost no knowlege on this.

 

I checked out this thread:

http://forums.adobe.com/message/2588737

 

and it is very close, except that it assumes that there is a named swatch as the source color - which there isn't.

 

The script I tried was .JS

 

I'm trying to have the script run on a bunch of .eps files in a folder:

- Select object which has specified CMYK value (0,7,34,10)

- Replace fill color of the selected object with another CMYK value (5,19,36,0)

- Save over the existing .eps

- Close

- Make coffee (optional)

 

Also, any books you can recommend for learning this stuff? For a noob.

Calling functions from UI palette

$
0
0

Hello,

From what I understand, you can't call complex functions from a scripted UI palette, only from "dialog" windows (which are usless in my case) because I need the persistance of a palette.

 

I have a series of scripts in use now that are  accessed from the usual "file-scripts folder" within Illustrator itself (about 27 of them).  I want to script a palette window so users can acces them without the usual mouse clicks down the menu system.

 

I'm able to call a simple "Hello World" type function using the "onClick()" method from a button of a scripted palette window, but I cannot use my regular working scripts inside a function that's called from the button.  In X-Code, I was able to write my scripts individually, then just add them to a main floating window via a separate function when they were completed.  But, I'm finding Javascript a little more tricky.

 

If I copy my other's script code into the function in the palette window script, it runs, but it runs before I click the button! --  After in runs, then the palette window is displayed(?).  If I try to use the execute() method with "onClick", the script just opens in the SDK, it will not and does run in Illustrator.

 

I take both of these as clear indications that I have no clue what I'm doing (or that I'm trying to do the impossible).

 

I did find someone with a similar problem, but they were scripting After Effects and were offered this solution:

 

system.callSystem ('afterfx -r "/C/Program Files/Adobe/Adobe After Effects CS3/Support Files/Scripts/GlobalVars.jsx"');

 

 

Is there anything I can do in Illustrator that will allow me to call (or execute) my other scripts/functions and have them execute within Illustrator?

 

Thanks for any and all help!

script takes more time to run single file

$
0
0

Hello everyone ,

 

i have written code to check text frame and text frame rectangular  box are in same in group if not i will move text frame to the rectangle frame group , it takes so much time to run a single file , this is my code can anybody say why it is taking so much of time

 

var fileArray,fileArray_buffer,fileArray_save_elements,fileArray_title,fileArray_SM_name;
var y_connec_coor, x_connec_coor,x_SM_Name_coor,y_SM_Name_coor,x_connector_position,y_connector_position;
var text_frame;
var sourceDoc;








read_ai1();
function read_ai1()
{
    sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files', '~' );    files = sourceFolder.getFiles("*.svg");    if(files.length == 0)
{      }        if ( files.length > 0 )     {          for ( file_iteration = 0; file_iteration < files.length; file_iteration++ )     {               sourceDoc = app.open(files[file_iteration]);   layer_file = sourceDoc.layers;    text_frame = sourceDoc.textFrames;    connector_array_inside_grp = [];           read_ai(activeDocument.groupItems);       var exportOptions = new ExportOptionsSVG();
var type = ExportType.SVG;
var fileSpec = new File(sourceFolder);
exportOptions.embedRasterImages = true;
exportOptions.embedAllFonts = false;
exportOptions.fontSubsetting = SVGFontSubsetting.None;
exportOptions.documentEncoding=SVGDocumentEncoding.UTF8;
exportOptions.cssProperties=SVGCSSPropertyLocation.PRESENTATIONATTRIBUTES;
//exportOptions.preserveEditability = true;
exportOptions.fontType=SVGFontType.SVGFONT;
sourceDoc.exportFile( fileSpec, type, exportOptions );


/*var exportOptions = new ExportOptionsSVG();                                     
var type = ExportType.SVG;
var fileSpec = new File(sourceFolder);
exportOptions.embedRasterImages = true;
exportOptions.embedAllFonts = false;
exportOptions.fontSubsetting = SVGFontSubsetting.None;
exportOptions.preserveEditability = true;
exportOptions.fontType=SVGFontType.SVGFONT;
sourceDoc.exportFile( fileSpec, type, exportOptions );*/
sourceDoc.close ();
}
}
alert ("completed");
}           function read_ai(Grps)
{    var lay_i, txt_i, x, y, xx, xy, count, txtFramesLen, t, t1;    for (lay_i = 0; lay_i < Grps.length; lay_i++) {    if (Grps[lay_i].locked) Grps[lay_i].locked = false;    theObj =sourceDoc.pathItems;
for(var j = theObj.length-1; j>=0; j--) {     if(theObj[j].pathPoints.length == 4 && theObj[j].stroked==false && theObj[j].filled==false)         {      x            = Math.round(theObj[j].pathPoints[0].anchor[0]);      y            = Math.round(theObj[j].pathPoints[0].anchor[1]);     txtFramesLen = Grps[lay_i].textFrames.length;      for (txt_i = txtFramesLen - 1; txt_i >= 0; txt_i--) {        var text_frame = Grps[lay_i].textFrames;               t  = Math.round(text_frame[txt_i].anchor[1]);        t1 = (Math.round(text_frame[txt_i].anchor[0]));        t3=t1-x;       if(t3==0)     {          theObj[j].move(text_frame[txt_i].parent,ElementPlacement.PLACEATEND);          }}}}}}

 

 

with regards,

 

yogesh.v

New to Illustrator scripting, looking to make a Compound Path from Existing Paths/Compound Paths

$
0
0

I am wondering how to select existing paths (normal paths and compound paths) and make a new compound path.  Google does nothing for me on this....

 

I have begun to understand the basics of targeting objects and doing some basic changes such as width, height, textFont, positioning and such...but the Scripting Guide is hard for me to wrap my head around as far as compound paths.

 

I am also having issues understanding the differences between object references that either do or don't have an "s" at the end. I assume there is some uniformity to why many object references have both. Could someone explain the reasoning?

 

Example

 

pathItem

pathItems

 

 

Thanks in advance!!

James

Adding enter or return key to an action

$
0
0

Hi all thanks for viewing this and thanks in advance for any help you can provide.  This might an easy thing to do but I've searched all over and haven't found an answer.  I'm running some variable data and I would like to print each piece once it's complete.  The problem I'm encountering is in my "batch" I add the action "Print" and it gets to the print script which I have to manually hit enter.  I've tried to find away to automate this by seeing if there's away to automate the "enter" key but unfortunately I have no luck thus far.  Does anyone know a work around for this?  I would like to do this in illustrator.  Please no recommendations to do this in other programs.  Thank you so much in advance!

Viewing all 12845 articles
Browse latest View live


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