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

Place 2 objects into a new layer and rename that layer

$
0
0

Hi All

 

Have a little problem and need your help:

- I have an ai with hundreds of objects in it. All in one layer.

- There are two types of objects: blocks and textlayers (numbers). So each block has a number on it's top.

 

http://i58.tinypic.com/mafmgg.jpg

 

What I finally need is a new layer structure:

- Each object+textlayer must be put in a separate layer AND that new layer must be renamed to the number which is inside that layer.Like that:

http://i58.tinypic.com/2wejfup.jpg

 

My first thought was to collect objects by it's position. For example: Position of the text object can be placed at x and y coordinates of the block, but + 2mm offset for margins. This would be the recognition point for the script to put them in the separate layer.

Or look for overlapping objects and put them in a new layer.

 

Also found something which can work with existing scripts if there can be written an additional one:

Here is a script for converting groups into layers and retaining group names:

http://forums.adobe.com/thread/892733

 

Here is a script to make groups out of overlapping objects:

http://js4ai.blogspot.be/2008/04/new-script-group-overlapping-objects.html

 

In theory if there would be a script for changing group names to the textlayer names, then the problem would be fixed in those three steps.

 

Does anyone know a solution for this? I'm not a developer, know almost nothing about coding.

 

Thanks!


execute photoshop script via illustrator cs5

$
0
0

Hi

 

Is it possible to execute Photoshop script via illustrator

I have 2 different script

script 1 work in illustrator with eps file and export as jpeg

script 2 where i want to trim the exported jpeg for illustrator in photoshop and save it back

I have 2 differnt script with me

can anyone help me to club both and run at same time..

 

Thank you
Appu

Save as FXG option not working from script. Am I doing this right?

$
0
0

I see that the Illustrator Scripting reference document for CC 2014 [1] has references to FXG, FXGSaveOptions, etc.  I thought I would give it a try to see if I can save a document to FXG.  Here is what I am trying:

 

var myDocument = app.documents[0];
var myTextFrame = myDocument.textFrames.add();
myTextFrame.position = [200,200];
myTextFrame.contents = "Hello World!"

var newFile = new File("c:/temp/fxgfile");
var fxgSaveOptions = new FXGSaveOptions();
myDocument.save(newFile,fxgSaveOptions);

 

This causes the file to get saved as fxgfile.ai and not fxgfile.fxg that I was looking for.

 

Any ideas?

 

Thanks,

Om

 

[1] http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2014/Illustrator% 20Scripting%20Reference%20-%20…

Script to make multiple layers in one task

$
0
0
From time to time I find the need to make many empty layers named A-Z. I use this when preparing a font drawn in Illustrator for moving to FontLab.

I have not found any ready made script to do this and would like a little help to make one. Or, if somebody would like to make this script it would be even more helpful.

The situation is this:
A full set of glyphs is ready in Illustrator and all are on Layer 1.
Artboard is set according to: http://font.is/?p=48
Glyphs are aligned to left on top of each other.
Need to make empty layers, A-Z and even more. Tedious by hand.
Then each glyph is moved from the sublayers to their own new layers. I could continue doing this part by hand.

I could of course make these layers in one file and copy them each time to each project but a script would be soooo much cooler.

Any help with this? Hints?

Thanks in advance.

how to clear clipboard

$
0
0

As the title says, how do i clear the clipboard while scripting with copy/paste functions?

 

Because i am affraid for crashes because too much items are on the copy buffer

 

Thanks.

Editing the leading on a created textFrame

$
0
0

Hi,

 

I have no idea why the following code will not work.

The text displays in the correct place with the correct contents but i cannot get the leading to change.

 

var textInfo = app.activeDocument.textFrames.add();

textInfo.name = "textInfo";

textInfo.position = [30,-30];

textInfo.contents = "A";

textInfo.autoLeading = false;

 

for(var i = 0; i<app.activeDocument.textFrames["textInfo"].textRange.characters.length; i++){

    app.activeDocument.textFrames["textInfo"].textRange.characters[i].characterAttributes.lea ding = 18;

    redraw();

    $.writeln(app.activeDocument.textFrames["textInfo"].characters[i].characterAttributes.lea ding);

    }


I have also tried textInfo.leading = 18; with no luck.


The write line function at the end is reading the correct leading but the line above is not editing it.


Adobe illustrator CS6, Mac OS 10.6, Javascript/extendscript

 

Also, not too sure what auto leading does so have tried both with and without.


Thanks,

Tom

How to assign values to an artboard and save them within the document?

$
0
0

Is there any chance to assign values to an artboard?

 

I've experimented with “tags”, but they only work for pageItems. (if the item which includes the stored data is deleted, the data is also deleted)

 

It is simple data like v1=true, v2=false, … I want to assign.

And it needs to be saved within the illustrator document.

 

Any suggestions? tips? workarounds?

 

thx in advance!

Resize artboard to content - works in Mac (CS6), not Win (CC)

$
0
0

Hello!

This code works perfectly in Illustrator CS6 for Mac:

 

function resizeArtboard() {

            app.redraw();

            app.activeDocument.artboards[0].artboardRect = app.activeDocument.visibleBounds;

            app.redraw();

}

 

It works like the menu option "Shrink artboard to fit content".

 

However, running this script in Illustrator CC for Windows, the result is different: the content is enlarged to fit the artboard instead.

 

How can I solve this?

 

Thanks in advance!

 

/Måns


Document preset & New document - Illustrator - Applescript

$
0
0

Hi !

Here is the problem i would like to resolve with appelscript.
I want to make a new file with units (millimeters)

I know i need to make a preset before making a new document ; but i don't know how to do !

 

Here is a part of the code i tried to do :

 

tellapplication "Adobe Illustrator"

 

activate

setdocument unitsofdocument presettomillimeters

makenewdocumentwith properties {width:297, height:210}

endtell

 

Thanks for your help !

Hindi numbers

$
0
0

Hi all, I want to switch my number format to hindi, I want to make it using javascript programmatically, is there any javascript sample to do that?

thanks.

Ai Packaging Script

$
0
0

Ok.. I'm sure this has been posted before (already searched, didn't find however), but does a file packaging script exist for AI? (one that collects all linked images and fonts and places them in one place) This would be IMMENSELY helpful to me if anyone can post a link to one or even be willing to write it.

 

OS: W7

AI Version: CS5

 

Thanks in advance!

Looking for "Replace with Symbol" script

$
0
0

So I am trying to replace gps points with a symbol I have created. I have found blogs referencing a script that can replace selected items with symbols saved in the symbols panel, but I can't seem to find the actual script! If anyone knows where I can find JET_ReplaceWithSymbol.jsx or any other script that can do the same function, it would be greatly appreciated!

A Script to Find and Replace Layer Names

$
0
0

Are there any scripts to find and replace layer names?

 

There is an excellent script available for Photoshop which allows you to not only replace words in layer names, but also insert words as Prefixes, Suffixes and Sequential Numbers.

The illustrator version of this script only allows sequential numbering: It doesn't offer find and replacing of words.

 

Ideally, it would be great if there was something that could do multiple find and replaces in one go:

(e.g.

You have layers like this Car, Dog, Bat

You enter: car(Option1), dog(Option2), Bat(Option3)

Your layers then become: Option1, Option2, Option3).

)

Tweaking the SaveDocsAsPDF script

$
0
0
Hello. Absolute scripting newbie here; will someone take pity...?

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!

Script taking far too long to execute

$
0
0
 
 var sel = app.activeDocument.selection;                       
for (i = 0; i < sel.characters.length; i++ ){            var aChar = sel.characters[i];    if(aChar.contents =="~")       {        sel.characters[i+1].characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT;        if (sel.characters[i+2].contents == "0" || sel.characters[i+2].contents == "1" || sel.characters[i+2].contents == "2" || sel.characters[i+2].contents == "3" || sel.characters[i+2].contents == "4" || sel.characters[i+2].contents == "5" || sel.characters[i+2].contents == "6" || sel.characters[i+2].contents == "7" || sel.characters[i+2].contents == "8" || sel.characters[i+2].contents == "9" ) {            sel.characters[i+2].characterAttributes.baselinePosition = FontBaselineOption.SUPERSCRIPT;         }        aChar.remove()       }
}        }
}

 

So I have this script that will convert a whole bunch of numbers in the text selection to superscript numbers. I am running this on a selection of about 44,000 words so I expected it to take a while, however it has been running for over 32 hours at this stage. Is there something I'm doing wrong? I'm on a deadline and this is becoming beyond a joke.


Anything similar to javascript's setInterval in ExtendScript?

$
0
0

I need a way to poll my server for new jobs for the illustrator script to work on every few hours.

I tried with $.sleep(), but that is blocking, I need a non-blocking way to do this.

Any advice?

 

Thanks!

Kashmira

Batch replace a colour with another colour

$
0
0

I have over 100 documents. In these documents, some of the objects use a regular black colour (e.g. C0, M0, Y0, K100). I need to replace it as a rich black (e.g. C75, M68, Y67, K90). The regular black colour is NOT saved as a swatch, so I can't just update the swatch. The objects are made of paths and shapes, some of which are in groups.

 

I found a script here and have updated it to suit my needs (The original script requires you to select an object, my update automatically selects all objects in the file). It works fine on a simple document that has a few layers. However, on more complex documents that have multiple nested layers, I get the following error:

 

Error 1302: No such element

Line: 9

->       myItem=docRef.pathItems[i];

 

 

Here is my code:

var docRef = app.activeDocument;

docRef.hasSelectedArtwork = true;

var iL=docRef.pageItems.length;

 

for (i=0;i<iL;i++){

     myItem=docRef.pathItems[i];

         

          if (myItem.fillColor=="[CMYKColor]" && myItem.selected){ //implement only for CMYK and selected

     var c1=0;

     var m1=0;

     var y1=0;

     var k1=100;

     var c2=Math.round(myItem.fillColor.cyan); // round the number ( 0,0012 => 0 )

     var m2=Math.round(myItem.fillColor.magenta); // round the number ( 6,8898 => 7 )

     var y2=Math.round(myItem.fillColor.yellow);

     var k2=Math.round(myItem.fillColor.black);

     if (c1==c2&&m1==m2&&y1==y2&&k1==k2){ // compare

     myItem.fillColor.cyan=75;

     myItem.fillColor.magenta=68;

     myItem.fillColor.yellow=67;

     myItem.fillColor.black=90;

      redraw();

                    } // if compare

                             

          } // if CMYK

     } // end for

 

How can I overcome the error.

Illustrator scripting with datasets & variables

$
0
0
I have a .ai file with 3 datasets containing 2 variables each. I am new to adobe scripting and am trying to write a script that will loop through the 3 datasets, swap out the variables, and save as 3 different .pdf files. I can loop and export, but don't know how to access the variables.

Here is a snipped from what I have:

for (var i=0; i< docRef.dataSets.length; i++){

var ds1 = docRef.dataSets.getByName('ABC'); // ABC is a client name, but numeric index is required
//var ds1 = docRef.dataSets.index(1); // this doesn't seem to work, but i need it to
docRef.activeDataset = ds1;

// I need to access the dataset variables here, where ClientName is a variable name within the dataset
client_name = ?????;

ds1.display();
app.redraw();

// ----- save changes
filepath = '/Users/me/Documents/clients/'+client_name+'.pdf';
saveInFile = new File( filepath );
pdfSaveOpts = getPDFOptions( );
docRef.saveAs( saveInFile, pdfSaveOpts );
}

Thanks for any help

importing data into illustrator with javascript

$
0
0

I would like to open a file dialog box seltect a CSV text file saved from Excel and import this into an array/variable/dataset in adobe illustrator using javascript. Have done some work with javascript but not a power user. Can't work out how to get the open dialog to appear.

Long term aim would be to use the data to plot a path which seems straighwforward enough, its the getting the info in bit I'm stuck on.

You do have to be able to select the file to import, this bit quite important.

Any help appreciated

Why can't set and get KerningMethod in Illustrator?

$
0
0

As Doc of Illustrator:

CharacterAttributes:

 

kerningMethodAutoKernType:
AutoKernType.NOAUTOKERN
AutoKernType.AUTO
AutoKernType.OPTICAL
AutoKernType.METRICSROMANONLY
r/wThe automatic kerning method to use.

But my code get KerningMethod:

Dim val As Double = oCharacter.CharacterAttributes.kerningMethod

It shows exception: the requested attribute is undefined for the text range

 

My code set KerningMethod:

oCharacter.CharacterAttributes.KerningMethod = 50

It shows exception: Enumerated value expected

 

Why? How get and set KerningMethod in Illustrator?

Viewing all 12845 articles
Browse latest View live


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