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

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.


How to duplicate artboard and move it relative to original?

$
0
0

Basically, I have an open AI document and would like to duplicate its artboard and then move it to a new position(X axis, 50pixels away from the original). Doesn't seem too hard, but I can't figure it out. This is for CS5.

 

 

 

var docRef = app.activeDocument;

 

var abSrc = docRef.artboards[0];

var abSrcX = abSrc.artboardRect[0];

var abSrcY = abSrc.artboardRect[1];

var abSrcW = abSrc.artboardRect[2];

var abSrcH = abSrc.artboardRect[3];

abSrcX = abSrcX + 1221;

var abSrcRect = [abSrcX, abSrcY, abSrcW, abSrcH];

 

 

var dupAB = docRef.artboards.add(abSrcRect);

 

The above works somewhat. Original artboard is 17" x 11" (1224px x 792px) and when I set abSrcX to anything above 1221, extendscript throws a PARM error. During one of my trial and error sessions, i decided to see what the geometricBounds of the document was:

 

$.writeln(docRef.geometricBounds); = 45,-12,1221.154296875,-780

 

So now I kinda see where I can't go over 1221, but why can't I?

 

I moved the artboard to the very top left of the document and i got the geometricBounds again and they were -6754.5,7038.5,-6463.5,6736.5, but still can't set abSrcX to anything over 1221.

 

the error is "an Illustrator error occurred: 1246458189 ('PARM')"

 

I've been trying to figure this out every which way that I can think of, but nothings working. Any help or input would be GREATLY appreciated!

 

EDIT:

 

So I tried this for the hell of it:

 

var abSrcX = 0;

var abSrcY = 1224;

var abSrcW = 1224;

var abSrcH = 792; (for some reason 792 translates to 6" inside illustrator, so i set this 432 to make it 11")

var abSrcRect = [abSrcX, abSrcY, abSrcW, abSrcH];

 

var dupAB = docRef.artboards.add(abSrcRect);

 

and it adds a new artboard and moves it to X, Y as designated. Not exactly what I want, but narrowing down the issue.

 

I try

 

var abSrcX = 1224;

var abSrcY = 0;

var abSrcW = 1224;

var abSrcH = 792;

var abSrcRect = [abSrcX, abSrcY, abSrcW, abSrcH];

 

var dupAB = docRef.artboards.add(abSrcRect);

 

and it throws that PARM error again, so now it really makes no sense!

 

EDIT2: i changed abSrcY to 10000 and now the artboard's height is really long, which makes even no more sense....unless I have the artboardRect(x, y, width, height) down wrong?

 

EDIT3: So after searching google some more, I found out what the problem is. artboardRect is TOP, LEFT, BOTTOM, RIGHT; and when I do:

 

var abSrcX = 1368;

var abSrcY = 0;

var abSrcW = 2592;

var abSrcH = -792;

   

var abSrcRect = [abSrcX, abSrcY, abSrcW, abSrcH];

//top left right bottom;

   

var dupAB = docRef.artboards.add(abSrcRect);

 

It works. BUT, I have no idea what the numbers are in relation to. The center of the artboard? Center of the document? And if I run it again and change...oh dear.

I think I just figured it out.

 

abSrcX is LEFT;

abSrcY is TOP;

abSrcW is RIGHT;

abSrcH is BOTTOM;

 

Taking that into account if I add (1224 + 144) to abSrcX and abSrxW it creates another artboard 2" away from the previous at 17" x 11". If I want to run it again, I just to add (1224 + 144) to abSrcX and abSrxW again. Now to figure out how to do this dynamically on the fly.

 

I would still like to hear some input on whether this is right or wrong and how I can improve it!

Is there any way to convert recorded actions into JSX Javascript file?

Changing decimal values to fractions

$
0
0

Does anyone know of a good way to convert decimal values to fractions for use in inch measurements? I have a script that works great but it returns values like 5.5638 and I'd rather it return the closest fraction answer like 5 9/16. 1/16ths would be great, but I'd settle for 1/8ths.

 

I started trying to come up with a large if with lots of > and < conditions, but I figured if anyone has already done this it might be better not to reinvent the wheel.

 

Thanks.

How get rotate of TextFrame?

$
0
0

I have a TextFrame : Rotate 45 ange

I want to get Rotate of this TextFrame and set to new TextFrame Add

I find in document, only exist function set Rotate to TextFrame.

How get rotate of TextFrame?

exportFile results in 'undefined' in Illustrator CC 2014

$
0
0

Hello-

 

I am creating a script to help version my files. the intended goal is to export the active document to a child directory as a PNG.  I have followed the CC 2014 scripting examples but the 'exportFile' method is returning undefined.   Also in the Object viewer that method is not returned on search.  I am trying to ascertain  if that method has been deprecated in this latest release.  I do not have experience with prior versions of Illustrator so I am not aware if how this functioned in past.

 

Has anyone had success with this method in CC 2014?  Any Clarity lent would be appreciated.

 

Brian in NYC

 

var watchfolder = "/watchFolder";

 

exportPNGWithTimestamp (watchfolder);

 

function exportPNGWithTimestamp (watchfolder){

var date = new Date;

var month = date.getMonth() +1; //for zero index

var day = date.getDate();

var time = date.toLocaleTimeString();

var type = ExportType.PNG24;

var fileSpec= new File(watchfolder + "/" + app.activeDocument.name + "_" + month + "_" + day + "_" + time + ".png");

app.activeDocument.exportFile (fileSpec, type);  

    }

creating outlines from text using javascript in Illustrator CS5

$
0
0

Hi everyone,

 

Is there a way to select all of the text on all artboards and CREATE OUTLINES using Javascript? I've googled and googled, but I can't seem to find any help. The text that Adobe provides for scripting has this option for saving to FXGs which is preserveTextPolicy or something similar, but I need the same type of solution for saving as an AI file or as a command before the save. I'm currently working in windows, but am writing this script for use on a MAC. If there isn't an internal way of doing this through Javascript, does anyone know of another?  I would imagine it would be possible through Applescript since it can access the application's GUI, but I'm not sure. A javascript solution would be preferable, but any solution would work at this point.

 

thanks,

Matt

Help with applescript command

$
0
0

I'm trying to use this command to change the colour of objects inside of a document using applescipt but i keep getting an error "adobe illustrator "can't get color"" the colour exists and is active on a document. I have read the manual on variables and i'm a little lost on what i'm doing wrong, heres what i've got so far:

 

tellapplication "Adobe Illustrator"

 

          ifcoloris "C=0 M=0 Y=0 K=90" then

 

                    setcolorto "C=0 M=0 Y=0 K=90"

 

          endif

endtell

 

any help would be apreciated, i understand this is quite basic but its all i have to start with at the moment


Is it possible in Extendscript/Javascript to 'Outline Stroke' a path

$
0
0

I'm trying to achieve the same command as enacted by Object > Path > Outline Stroke.

 

I can't find any reference to a method for this in the Javascript reference PDF, and you can't trigger menu commands in Javascript.

 

Applescript allows you to access the menu commands, so I wrote this:

 

tell application "Adobe Illustrator"

    set thisDoc to current document

    set locked of layer ("walls") of thisDoc to false

   

end tell

 

tell application "System Events"

    click menu item "All" of menu "Select" of menu bar item "Select" of menu bar 1 of process "Adobe Illustrator"

       

    click menu item "Outline Stroke" of menu "Path" of menu item "Path" of menu "Object" of menu bar item "Object" of menu bar 1 of process "Adobe Illustrator"

   

end tell

 

But it has a very annoying problem: if you run the script form within Illustrator the 'Outline Stroke' command fails. But, if you run the script in the Applescript editor with the illustrator document open it works. Which is just plain weird. If anybody understands why this is the case I'd love to hear the reason (and fix).

 

If anybody has any ideas for successfully outlining strokes in either Javascript or Applescript please respond.

 

Thanks,

 

Barry

How do I target different version of Illustrator?

$
0
0

Using #target Illustrator from the toolkit want to open in AI 17.  I have both 17 and 18 installed but want it to run in 18.  How can I target each with the directive?

Applescript: Removing Groups and Layers

$
0
0

This should be a simple task, but I still haven't figured out how to do it.

 

I have a set of page items, and the are contained in groups inside of layers inside of layer inside of layers.

How can I remove the layers easily?

I looked at the reference guide, and attached the screenshot where it explains how to use the "delete" command to remove containers of objects.

But I still dont' understand how to order the command correctly:

delete page item of layer?

delete layer of page item?

delete page item of layer of page item?

None of these work.

For now, I've just used an action, but it would be helpful if I could do it within a script.

 

Any help is appreciated.

Thanks,

 

Ben

Screen shot 2009-12-21 at 10.08.25 PM.png

Split Text into Layers

$
0
0

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

How can i make it auto line alignment in ScriptUI?

$
0
0

line.jpg

 

I want that form recognize new line character. (like '\n')

 

So I programmed like this. But it's not working.

 

//////////////////////////////////////////////////////////////////////////////

var win =new Window ("dialog", "test");
win.orientation = "column";

 

var form1 = win.add ("edittext", undefined, "");
form1.onChanging = function(){
  if(form1.text.search("\n") == true){
   form2.active = true;
  }
}

 

var form2 = win.add ("edittext", undefined, "");

var form3 = win.add ("edittext", undefined, "");

 

win.show();

 

//////////////////////////////////////////////////////////////////////////////

 

How can i make it auto line alignment in ScriptUI?

 

Is it possible?

How reset the rotation of a PageItem (or access it's matrix at least) ?

$
0
0

I'd like to apply rotation to a few PageItem instances, but would like to reset the rotation first so it doesn't accumulate when I run the same script multiple times. I'm having a hard time trying to figure out how to restet the transformation matrix.

 

I've spotted this post which is close to what I need but it's a bit old now.

It looks like there isn't a matrix property anymore.

This:

 

alert(app.activeDocument.selection[0].matrix);

ouputs undefined

 

I've tried

 

app.activeDocument.selection[0].transform(app.getIdentityMatrix());

but it seems transformations are accumulated, multiplied, not reset.

 

If I want to reset the rotation of a PageItem, how would I go about doing that ?

 

Thanks,

George

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

Batching In Illustrator??

$
0
0

In PhotoShop CS3, you can select File/Automate/Batch, and run an Action on an entire folder.  I don't see that option in Illustrator CS3?  Is there a way to run an action on an entire folder?

 

I'm attempting to save many EPS images as PNG images, and would really like to retain "vector attributes" - is any of this possible???

 

Thanks for any help.

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!

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.

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!

Scriptographer for cs6

$
0
0

Anyone know if there is an alternative to scriptographer until will be released a new version ?

Viewing all 12845 articles
Browse latest View live


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