Quantcast
Channel: Adobe Community : All Content - Illustrator Scripting
Viewing all 3666 articles
Browse latest View live

Expand dialog box in script

$
0
0

when i am using excute command in script (Expand3) to expand text and objects.

but i need always click ok to run expand process every time. is there any way to do with out Expand dialog box?

Screen Shot 2016-06-14 at 4.41.33 PM.png

 


Save eps with specific name using Applescript

$
0
0

Hi everyone i want to save .eps file to current open illustrator file location with specific name for Ex .XXXX_FINAL.eps

i tried some thing similar  - can any one help

tell application "Adobe Illustrator"
 activate  set theName to name of current document  set theNamecount to count of theName  set theOutdatedPathObj to the file path of current document  set thePath to (POSIX path of theOutdatedPathObj) as string  set pathCount to count of thePath  set pathCount to (pathCount - theNamecount)  set newPath to (text 1 thru pathCount of thePath)


 save current document in file newPath as eps ¬  with options ¬  activate
end tell

JS how to split the object to two diffrent parts ,like this:

$
0
0

JS how to split the object to two diffrent parts ,like this:002.jpg

How to export selection in AI CC 2015?

$
0
0

Hi All,

 

I have just updated to AI CC 2015 latest version. I see that we have an option to Export Selection.

I was trying to trigger this through script and haven't had much luck.

 

I tried this too..

executeMenuCommand("exportSelection");

 

But, the File browser opens up asking the user for the destination path.

I was hoping to find a way without user interaction.

 

Is there a method that can be called? I haven't found anything so far, except workarounds.

 

Any ideas?

 

Thanks,

Poorti

How to Switch illustrator Documents using Script

$
0
0

How to Switch illustrator Documents using Script for EX: Command + Tab in mac | Control + Tab in PC

 

Screen Shot 2016-06-15 at 6.35.21 PM.png

 

Screen Shot 2016-06-15 at 6.35.44 PM.png

Linked files name

$
0
0

Hi again guys!

Is there a script to copy the file name and extract some

charactes from the linked and selected .eps file?

 

Ex:

> Original name of the linked and selected eps file:

FILE1.ASD.eps

 

> Extract 5 letters only from that name with the script:

FILE1

 

I have to open many files but I wanna copy

the file name so easy like this with a little script.

 

I just need the code that and will put it in a button.

Many thanks for your help guys!

How can I select a tool programmatically?

$
0
0

Hi All,

 

I am using AI CC 2015.

I have a requirement to select the Group Selection Tool when I click on a button on my HTML5 extension.

 

So far, haven't found anything that can select a tool using scripts.

 

Found how to do it through a C++ plugin easily though. Here all all the methods that can be used to go about it.

#include <AITool.h>

name = kToggleDirectSelectTool
AIAPI AIErr(* AIToolSuite::GetToolNumberFromName)(const char *name, AIToolType *toolNum)
AIAPI AIErr(*  GetToolHandleFromNumber )(AIToolType toolNum, AIToolHandle *tool)
AIAPI AIErr(*  SetSelectedTool )(AIToolHandle tool)

 

 

But I don't want to include a plugin with my extension. I was hoping it could be done through the extension itself.

 

Can anyone help?

an Illustrator error occurred: 1346458189 ('PARM')

$
0
0

Hello everyone,

 

I am trying to open some documents in Illustrator CS4 by javascript, walk through all layers including sublayers, doing something (for now just reading the layernames and showing them at an alert), closing the document and continue with the next document in the given folder until all documents in that folder are done.

 

By doing so I found an error I never have seen so far and I cant figure out where it comes from exactly to get rid of it.

The Error an Illustrator error occurred: 1346458189 ('PARM') appears randomly when cycling through the layers of the document but only every second document, so I guess there might be something wrong with closing a document and realeasing all references but I could not figure out what.

 

Maybe someone got an idea on this problem? Posting my sourcecode (just a simple test-code) below.

 

 

#target illustrator

 

var sourceFolderPath = "/e/TestAI";

var destinationFolderPath = "/e/TestZielverzeichnis";

var fileNameDefinition = "*.ai";

var sourceFolder = new Folder(sourceFolderPath);

var destinationFolder = new Folder(destinationFolderPath);

 

runCheckTool();

 

function runCheckTool() {

var contentInput = sourceFolder.getFiles(fileNameDefinition);

var fileRef;

var docRef;

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

fileRef = null;

docRef = null;

try {

fileRef = new File(contentInput[i]);

docRef = open(fileRef);

} catch(e) {

alert("# 1: " + e);

}

 

try{

checkLayers(docRef.layers);

} catch(e) {

alert("# 2: " + i + " " + e);

}

 

try {

docRef.close(SaveOptions.DONOTSAVECHANGES);

alert("end file index: " + i);

} catch(e) {

alert("#3: " + e);

}

}

}

 

function checkLayers(layerRef) {

var countLayers = layerRef.length;

for (var j = countLayers - 1; j >= 0; j--) {

if(layerRef[j].layers.length > 0) {

checkLayers(layerRef[j].layers);

}

alert ("Layer: " + layerRef[j].name);

}

}

 

 

Screenshot001.png


Raster pathItems in layer

$
0
0

Hey.  I'm loosing it here.  Trying to setup a loop through a layer to rasterize each pathItem as well only raster the ones visible, which I haven't gotten to yet. I can't seem to get it to give me just the path items though.  Maybe my syntax is wrong.  Help is much appreciated.

 

   function rasterLayers() {

        var myLayer = idoc.layers["My Special Layer"];

 

 

    for(var a=0;a<myLayer.layers.length;a++){

        var currentItem = myLayer.layers.pageItems[a];

        currentItem.selected = true;

        idoc.rasterize( currentItem ,currentItem.visibleBounds, newoptions);

}}

rasterLayers();

How do I set http headers when using the BridgeTalk HttpConnection object?

$
0
0

Hi,

 

I am trying to make http post requests from within Illustrator ExtendScript (via BridgeTalk) and for the most part it is working. However, the documentation on using HttpConnection is non-existent and I am trying to figure out how to set http-headers. The HttpConnection object has both a requestheaders and responseheaders property so I suspect it is possible.


By default, the post requests are being sent with the Content-Type header "text/html", and I would like to override it so that I can use either "application/x-www-form-urlencoded" or "multipart/form-data".

 

Here is what I have so far:

 

var http = function (callback) {

 

    var bt = new BridgeTalk();

    bt.target = 'bridge' ;

   

    var s = '';

    s += "if ( !ExternalObject.webaccesslib ) {\n";

    s += "  ExternalObject.webaccesslib = new ExternalObject('lib:webaccesslib');\n";

    s += "}\n";

    s += "var html = '';\n";

    s += "var http = new HttpConnection('http://requestb.in/1mo0r1z1');\n";

    s += "http.method = 'POST';\n";

    s += "http.requestheaders = 'Content-Type, application/x-www-form-urlencoded'\n";

    s += "http.request = 'abc=123&def=456';\n";

    s += "var c=0,t='';for(var i in http){t+=(i+':'+http[i]+'***');c++;}t='BEFORE('+c+'):'+t;alert(t);\n"; // Debug: to see what properties and values exist on the http object

    s += "http.response = html;\n";

    s += "http.execute() ;\n";

    s += "http.response;\n";

    s += "var t='AFTER:';for(var i in http){t+=(i+':'+http[i]+'***');}alert(t);\n"; // Debug: to see what properties and values have been set after executing

 

    bt.body = s;

 

    bt.onResult = function (evt) {

        callback(evt);

    };

   

    bt.onError = function (evt) {

        callback(evt);

    };

   

    bt.send();

};

 

Things to note:

 

1. If I try setting the requestheaders properties like in my code above, the request fails. If I comment it out, the request succeeds. The default value for requestheaders is undefined.

2. Examining the http object after a successful request, shows the reponseheaders properties to be set to: "Connection, keep-alive,Content-Length, 2,Content-Type, text/html; charset=utf-8,Date, Wed, 24 Jun 2015 09:45:40 GMT,Server, gunicorn/18.0,Sponsored-By, https://www.runscope.com,Via, 1.1 vegur". Before the request executes, the responseheaders is set to undefined.


If anyone could help me set the request headers (in particular the Content-Type header), I would be eternally grateful!


Thank you


UPDATE:

Using the ExtendScript SDK, I have discovered the responseheaders property is an array, of this format: ['Connection', 'keep-alive', 'Content-Length', 2, 'Content-Type', 'text/html' .........]

I have tried to set the requestheaders to the same format (I have tried both ['Content-Type', 'application/x-www-form-urlencoded'] and ['Connection', 'keep-alive', 'Content-Length', 2, 'Content-Type', 'application/x-www-form-urlencoded' .........]) with no luck



script to save .ai files in a folder to .svg file

$
0
0

hello everyone ,

 

i am an beginner in javascript can anybody help me to save .ai fies in a folder to .svg files , also  while saving as .svg file

 

image location : to be embedded

preserve illustrator editing capabilities checkbox to be ticked , my version is illustrator cs5 can anybody help me in the code .

 

 

with regards,

karthi

Turn selected AI sublayers into top-level layers?

$
0
0
Hi, all!

I wanted to ask if by chance any of the scripting gurus here happen to have written an AI script that will take a number of selected sublayers/sub-sublayers and move them so they become top-level layers?
I am really needing this very badly, given that After Effects can only handle AI layers as separate entities. So I find myself moving tens, even hundreds of nested sublayers to the top level all the time.
Is it possible this script exists already?

How to check if a pageItem lies completely inside another pageItem?

$
0
0

Hi All,

 

I am working on AI CC 2015 latest release.

I have a scenario where I need to check whether an art item or page item does not overflow the boundary of it's parent page item.

Is there any way to detect it?

 

The bounds won't work as they return bounds w.r.t a rectangle.

 

Please refer to the following images to understand better what I mean to say.

scenario_1.png

The above should return true as the rectangle is inside the pageItem.

 

The below scenarios should return false,

scenario_2.png

scenario_3.png

Any guidance, please?

 

Regards,

Poorti

Script to pull pantone colors from a dataset and recolor selected areas

$
0
0

I am looking for a script that will pull information from a dataset and apply those colors to the necessary paths/compound paths. I am just starting to try an work with scripting so my knowledge level is low. Is there a way to have a path with a pre determined attribute note (ex. a) selected then to select same fill color and change those selected objects to the colors assigned to "a" in the dataset and do the same thing with a secondary color as well? As seen in the image, the blue block in the center would be "a" and the yellow would be "b" , then select same color fill would be executed from those two base points.

Screen Shot 2016-06-21 at 11.16.11 AM.png

Error while run Javascript in MAC

$
0
0

Can anyone help to solve this problem, i am using javascript on mac osx.

Screen Shot 2016-05-04 at 11.08.33 AM.png


Tweak required in Applescript

$
0
0

Hi Can any help me to tweak below mention script

Concept : this script will save .eps to current open .ai file location

Problem : But i want to add an specific file name for example ( filename_EPS.eps) even i did the specific file name also, But i am getting .ai from current open file

see this | Screen Shot 2016-06-22 at 2.44.10 PM.pngwhen i save my file

 

 

 

tellapplication "Adobe Illustrator"

activate

  settheNametonameofcurrent document

  settheNamecounttocountoftheName

  settheOutdatedPathObjtothefile pathofcurrent document

  setthePathto (POSIX pathoftheOutdatedPathObj) asstring

  setpathCounttocountofthePath

  setpathCountto (pathCount - theNamecount)

  setnewPathto (text 1 thrupathCountofthePath)

 

  setfullPathto (newPath& theName)

  setEPS_PathtofullPath& "_EPS.eps"

savecurrent documentinfileEPS_Pathaseps¬

  with options¬

  activate

endtell

Illustrator VBA scripting 101 - via Excel

$
0
0

This post will attempt to introduce newcomers to Illustrator Visual Basic Scripting (well, not actually vbs, but rather tru VBA, Visual Basic for Applications). I personally prefer vba over bvs for a number of reasons. First, I always have Excel and Illustrator open, so it makes sense for me use it to drive Ai. Second, I usually need to transfer data between the two programs. Third...I love the Excel IDE...ok, let's get right into it.

 

 

- Open Excel

- hit Alt+F11, to bring up the editor

- in the Tools menu, click on References...

- add a reference to "Adobe Illustrator CS5 Type Library"

- in the Personal.xls (or in any other book) add a Module. Personal is a global workbook that is always available. If you don't see it, go back to Excel and record a macro, anything will do. That will create the Personal file.

- and type the following in that module

- we have to continue the tradition and do the "HelloWorld" script

 

Sub helloWorld()    Dim iapp As New Illustrator.Application    Dim idoc As Illustrator.Document    Dim iframe As Illustrator.TextFrame       Set idoc = iapp.ActiveDocument    Set iframe = idoc.TextFrames.Add       iframe.Contents = "Hello World from Excel VBA!!"       Set iframe = Nothing    Set idoc = Nothing    Set iapp = Nothing
End Sub

 

- save Personal book

- open Illustrator and create a new document first

- to run, move the cursor anywhere inside the Sub...End Sub and hit F5

 

that's it for now...in the following posts we'll move the text to the middle of the page, create new documents, get data from an Excel Range to Illustrator, get data from Illustrator text frame to an Excel Range...and more, hopefully.

 

questions? comments?

What's new in CC2015.3

$
0
0

This is not really a "question" because there's probably many answers (hopefully!)

 

Okay, here is what I found in the OMV, (Illustrator 20 Type Library) and I have no idea what and how to use it, just like some of the other things in there.

 

Document.processGesture (gesturePointsFile: string )

Adobe Illustrator 20 Type Library

Process a gesture based on input points.

gesturePointsFile: Data Type: string

File Path containing points constituting the gesture.

Looping through all items on a page

$
0
0

I am trying to create a script that loops through all the textand path items on a page, sets some text attributes and depending on the name of the item group it with others of the same name. The script I have at the moment sometimes works and sometimes doesn't. It always sets the text attributes, but sometimes will only move say 4 of the seven items with the name xAxisLabel to the group xLabels, other times it will move 3 or 5. Its the same with the path items also, really can't work this out and would appreciate any help

 

 

//Selects the graph before to scale them and turns off the pixel align so that values of 1 decimal place can be applied to strokes

doc.selectObjectsOnActiveArtboard(); 

var sel = doc.selection;

sel.pixelAligned=false

 

 

var item

 

 

var xLabels = layer.groupItems.add();  //create group for xAxis

var yLabels = layer.groupItems.add();  //create group for xAxis

var yTicks = layer.groupItems.add();  //create group for xAxis

 

 

//Loops through  ungrouped text items and set horizontal scale, spot black and tabular lining on figures

for (var i = 0; i < layer.textFrames.length; i++) {

    item=layer.textFrames[i];

    $.writeln (item)

    item.textRange.characterAttributes.textFont = textFonts.getByName("Metric-Regular");

    item.textRange.characterAttributes.figureStyle=FigureStyleType.TABULAR

    item.textRange.characterAttributes.fillColor=myBlack;

   

    //move labels on xAxis into the same group

    if (item.name=="xAxisLabel") {

         item.moveToEnd(xLabels);

     }

 

    //move labels on yAxis into the same group

     if (item.name=="yAxisLabel") {

            item.moveToEnd(yLabels);

     };

 

};

How do I flatten the layers in an illustrator document using extendscript

$
0
0

The nearest I can find is

   activeDocument.mergeVisibleLayers(); 

 

But this doesn't work in illustrator CS5

 

Thanks

Viewing all 3666 articles
Browse latest View live


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