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

batch change dpi from 72 to 300 and export as jpg

$
0
0

Hi All,

 

I have searched high and low, and have yet to find a script that will accomplish this task. I am in need of a script that will change Illustrator's default 72 dpi, to 300 dpi so I can print a series of (about 200) respectable looking images. They also need to be exported to jpg.

 

Is this possible to do in batch?

 

I have tried countless approaches. The closest I have come is using Graphic Converter Pro, unfortunately it cannot change the dpi from 72 to 300 (as far as I could tell). Any help is greatly appreciated. I have access to Mac OS and Windows. I've been trying to tackle this for quite some time. Thank you!


assign text through java script

$
0
0

Hello All,

 

This question might have been asked earlier but i couldnt find a clear cut answer to this. So here goes. i am trying to localise an image across different languages and though it was best to use illustrator capabilities. For this purpose i wanted to create the image file and leave the test fields empty and make them dynamic. The idea is to then run a Javascript from illustrator that would essentially populate the dynamic text field from an external data source. However i am not able to manually create such text placeholder on the illustrator file which can later be accessed as a variable from the javascript. Any help would be greatly appreciated.

 

Note: I know this can be done by importing it to flash and then setting the variable using the actionscript but i was hoping to tackle the problem from the illustrator side itself

 

Thanks a ton

Change Folder.current to location of script (.jsx) file?

$
0
0

All,

 

I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.

For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:

 

var w = new Window ("dialog");
var f = new File ('~/Desktop/transparencyGrid.jpg');
w.add ("image", undefined, f); 
w.show ();

 

However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:

 

var w = new Window ("dialog");
var f = new File ('../../../transparencyGrid.jpg');
w.add ("image", undefined, f); 
w.show ();

 

But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.

I say that because when I do this:

 

alert(Folder.current);

 

The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.

 

So, is there a way of setting Folder.current to the location of the actual script?

Creating Multi-Page PDF from a Layerd Illustrator file (script)

$
0
0

Often times when designing a logo I create different versions and variable options on layers. This can result in several layers in one Illustrator file. Is there an easy way or an existing script that will allow me to (with one click) create a multi-page PDF consisting of all the layers within my .ai file? The current method is turning on each layer, performing a save-as (PDF), then turning off said layer and turning on the next layer and repeating the task and so-on-and-so-forth, etc … It becomes tedious and quite often I save over the previous version, forgetting to re-name it or forget to perform a save on a certain layer. Can anyone help with some advice? I have never written my own script before but am not opposed to trying, where do I begin?

Any help is appreciated.

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

Javascript to make selection of top level group?

$
0
0

Does anyone know of a way to select a top level group by index?

 

For example, i have many files with deeply nested groups and i want to select all artwork in only the top level groups and create an artboard around the visible bounds of said group.

 

I've been able to loop through the groupItems of the document, but i cannot seem to differentiate between top level groups and sub groups. In other words, the loop is working properly, but it is creating an artboard around the top level group, then around each subgroup and each group within that subgroup.

 

In the attached image, you can see that there are 5 top level groups in this document. However, basically everything else is grouped within those groups. for example, the "YouWho" logo is approximately 100+ path items grouped together. the information on the collar is grouped several times in a complex hierarchy as well.

 

The obvious solution is to ungroup everything and then regroup each shirt piece as 1 group. unfortunately, that in itself is more time consuming than manually creating the artboards and then the file is not very clean if we ever need to get back inside it to change/fix something.

 

i'm imagining some way to loop through the subgroups and ignore them if they are within the geometric bounds of the top level?? But i'm not really sure where to start on that code..

 

This is the code i have currently that is creating artboards around each groupItem, but also around each groupItem within the top level... it also throws an error because i think illustrator can't keep up with creating the artboards that fast? when i run the same script on less complicated artwork it works fine.

 

var docRef = app.activeDocument;
var aB = docRef.artboards;
var gI = docRef.groupItems;


for (a = 0; a< gI.length; a++){    var currentGroup = gI[a];    currentGroup.selected = true;    var vB = currentGroup.visibleBounds;    aB.add(vB);//an Illustrator error occurred: 1346458189 ('MRAP')
}   

 

any ideas how to isolate that top level group and ignore the rest?? Thanks folks.

 

Screen Shot 2015-01-05 at 11.06.17 AM.jpg

batch change dpi from 72 to 300 and export as jpg

$
0
0

Hi All,

 

I have searched high and low, and have yet to find a script that will accomplish this task. I am in need of a script that will change Illustrator's default 72 dpi, to 300 dpi so I can print a series of (about 200) respectable looking images. They also need to be exported to jpg.

 

Is this possible to do in batch?

 

I have tried countless approaches. The closest I have come is using Graphic Converter Pro, unfortunately it cannot change the dpi from 72 to 300 (as far as I could tell). Any help is greatly appreciated. I have access to Mac OS and Windows. I've been trying to tackle this for quite some time. Thank you!

Illustrator Crashing When Running Script

$
0
0

Hi!

 

So I have some Javascript I've compiled from sources and written myself to accomplish the task of duplicating an object across and down a page, along with adding a few elements at the end.

 

I must say it works pretty well and correctly, and I know this because it does so with SIMPLE vector artwork.  Anything beyond a solid fill, single color background and Illustrator crashes.

 

I've tried this on numerous machines, from the ancient to the cutting-edge, CS5 to CC 2017, and the result is always the same....CRASH!

 

Can anyone help me in figuring out the cause of failure?  Is it, perhaps, that I am trying to do too much with Javascript, or that my handle on the language is poor and inefficient?

 

Any help would be appreciated.

 

Code:

 

########################################################################################## ###########################################

 

//Variables established / The script will proceed if something is selected...

 

 

if (app.selection[0] != null) {

 

 

  var myDoc = app.activeDocument,

  selectedArt = myDoc.selection[0],

  xclone = 4, // set number across

         yclone = 6, // set number down

  horOffset = 162,  // set horizontal offset (pixels)

  verOffset = -162,  // set vertical offset (pixels)

  myDuplicate,

  i = 0

         j = 0

        

 

 

//Duplicates the selection along the x axis

 

 

  for (i;i < xclone;i++){

        if (i === xclone) { break; }

  myDuplicate = selectedArt.duplicate();

  myDuplicate.position = [selectedArt.position[0] + horOffset * (i + 1), selectedArt.position[1] + verOffset * (0)];

           

  }

 

 

//Groups all objects in the active document

 

 

     for ( h = 0; h < myDoc.pageItems.length; h++ ) {

            myDoc.pageItems[h].selected = true;

        }

        var docSelection = new Array;

        docSelection = app.activeDocument.selection;

  

        var Group1 = app.activeDocument.groupItems.add();

 

          if (docSelection.length > 0) {

               for (h = 0; h < docSelection.length; h++) {

                    docSelection[h].moveToEnd(Group1);

               }

          }

 

//Duplicates the selection (Group1) along the y axis

 

    for (j;j < yclone;j++){

        if (j === yclone) { break; }

  myDuplicate = Group1.duplicate();

  myDuplicate.position = [Group1.position[0] + horOffset * (0), Group1.position[1] + verOffset * (j + 1)];

  }

 

 

//Groups all objects in the active document

 

 

     for ( h = 0; h < myDoc.pageItems.length; h++ ) {

            myDoc.pageItems[h].selected = true;

        }

        var docSelection = new Array;

        docSelection = app.activeDocument.selection;

  

        var Group2 = app.activeDocument.groupItems.add();

 

          if (docSelection.length > 0) {

               for (h = 0; h < docSelection.length; h++) {

                    docSelection[h].moveToEnd(Group2);

               }

          }

 

//...Otherwise an exception is thrown

 

  }

else {

  alert("You must have an object selected.");

  }

 

 

{

   

//Resize Artboard [? , Height , Width , ?] (pixels)

 

app.activeDocument.artboards[0].artboardRect = [0,1134,871.2,0];

 

//Aligns selection (Group2) to artboard and deselects all

 

 

    {

    var myDoc = app.activeDocument; 

        app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM; 

    var abIdx = myDoc.artboards.getActiveArtboardIndex(); 

    var actAbBds = myDoc.artboards[abIdx].artboardRect; 

    var obj2move = Group2; 

        obj2move.position = new Array ((actAbBds[2]-actAbBds[0])/2 - obj2move.width/2, (actAbBds[3]-actAbBds[1])/2  + obj2move.height/2);

        app.selection = null;

    }

 

//Creates named paths to size and specifies a CMYK 100% Black fill [? ,  ? , Width , Height] (pixels)

 

    {

    var laserLine = app.activeDocument.pathItems.rectangle(0,0,9,1134);

        laserLine.name = "laserLine";

    var eyeMark = app.activeDocument.pathItems.rectangle(0,0,14.4,9);

        eyeMark.position = [856.8,-1125];   //[X,Y] (pixels)

        eyeMark.name = "eyeMark";

    var k = new CMYKColor;

        k.cyan= 0;

        k.magenta = 0; 

        k.yellow = 0;

        k.black = 100;

 

        laserLine.fillColor = k;

        eyeMark.fillColor = k;       

        }

}       

 

 

{

   

//Variables established / selects eyeMark path and duplicates along the y axis    

       

    verOffset = 162, // set vertical offset (pixels)

    yclone = 6, // set number up (offset is + now)

    myDuplicate,

    k = 0

       

    app.activeDocument.pageItems.getByName("eyeMark").selected = true;     

         

    for (k;k < yclone;k++){

        if (k === yclone) { break; }

  myDuplicate = eyeMark.duplicate();

  myDuplicate.position = [eyeMark.position[0] + horOffset * (0), eyeMark.position[1] + verOffset * (k + 1)];

  }

 

}

 

########################################################################################## ###########################################


CS6+ executeMenuCommand, pattern swatch

$
0
0

Hi all, I'm trying to create a Pattern Swatch out of the Selected Object, so I'm using

 

app.executeMenuCommand ('Define Pattern Menu Item');

 

this successfully adds the swatch to the swatches panel, but it also brings up the Pattern Options Panel and goes into "Pattern Editing Mode" where in the UI one could either click on "Cancel", "Done" or "Exit Editing Mode" buttons...

 

the problem is I can't exit out of the Pattern Editing Mode, has anyone discovered if there is a MenuCommand for it?

 

thanks

Illustrator Script - Open TIFF or PSD without options dialog

$
0
0

I'm writing a script that opens a series of TIFF files in Illustrator and re-saves them as EPS files after performing a few operations. I specifically need to open each file and "Convert Layers to Objects" per the TIFF Import Options. While I'm currently working with TIFF files for my input, I can change that to PSD input files if necessary so if you have any info regarding that instead of TIFFs, that may help too.

 

App.open() works to get my files open, but it also brings up the TIFF Import Options dialog box, which hinders the script's efficiency because this will need to run with little to no human interaction outside of an initial button press to start the script.

 

It seems like the answer would be in calling the open() method with a second argument for my open options, but I can't find any documentation that outlines the possible open options. Can anyone point me in the direction of the proper documentation for this or tell me how to figure out the open options for opening TIFFs in Illustrator?

 

Note: This project requires that I specifically open a layered TIFF or PSD directly in Illustrator so unfortunately importing my files into an existing file and then embedding them won't suffice here.

Saving documents via Scripts: Get current file name and set save path/file type

$
0
0

I am writing a script that will:

 

-Make all layers invisible

-Make a layer named "background" visible

-Delete all the invisible layers

-Save the docment as an EPS file (leaving the original document untouched)

 

I am new to scripts and so have based my script by copying code from other scripts.

 

Here is my code:

 

var doc = app.activeDocument;

var name = doc.name;

 

 

var hide = function (){ // hide all layers (based on http://forums.adobe.com/thread/644267)

     var L=doc.layers.length;

     for (j=0;j<L;j++){  doc.layers[j].visible=false; }

}

hide();

 

 

// loop through all layers

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

 

 

 

 

 

              // Create the illusrtratorSaveOptions object to set the AI options

    var saveOpts = new IllustratorSaveOptions();

 

    // Setting IllustratorSaveOptions properties.

    saveOpts.embedLinkedFiles = true;

    saveOpts.fontSubsetThreshold = 0.0

    saveOpts.pdfCompatible = true

 

 

 

 

 

 

//Set up Variable to access layer name

          var currentLayer = app.activeDocument.layers[i];

 

// Loop through the layers and make the back ground layer visible

          if (currentLayer.name == "Background") {

                    docName = name + currentLayer.name+".eps";

                    currentLayer.visible = true;

                    }

 

 

}

 

 

// Delete Invisible Layers (based on http://www.cartotalk.com/index.php?showtopic=7491)

var myDoc=app.activeDocument;

var layerCount=myDoc.layers.length;

for (var ii = layerCount - 1; ii >= 0; ii--) {

    var currentLayer = myDoc.layers[ii];

    currentLayer.locked = false;

    var subCount = currentLayer.layers.length;

    for (var ss =subCount -1; ss >= 0; ss--){

        var subLayer = currentLayer.layers[ss];

        subLayer.locked = false;

        if (subLayer.visible == false){

            subLayer.visible = true;

            subLayer.remove();

            }

        }

    if (currentLayer.visible == false){

        currentLayer.visible = true;

        currentLayer.remove();

        }

    }

 

// Save Out Document with New Name

 

var saveName = new File ( doc.path + "/" + docName );

doc.saveAs( saveName, saveOpts );

 

 

 

Everything works fine except:

1) It saves the document with the name AdobeIllustratorBackground as opposed to the name of the document

 

Also, I am not sure how to tell the script to save as EPS and to specify the save location.

 

Could some one give me some pointers?          Thanks!

call/run applescript from javascript

$
0
0

Hi,

How to call applescript code from javascript..

I want to run some applescript code via javascript in illustrator

 

pls help

Can you set a file to "self destruct" after a set period of time?

$
0
0

Hi!

 

I have someone interested in using a script that I had made. I would like to let them use it but I want to have some control over the period of time they are able to. My plan is to encrypt the script and hopefully set it to self destruct after a year, so they need a new file from me to continue using it. This way, if we stop doing business they can no longer use the script.

 

Is there a simple way to do something like this?

 

Thanks!

how to access https site from javascript socket object

$
0
0

HI ,

 

I'm new to SSL's and scripting.

 

I have written code to access http site and it is working.Below is the code.The script is failing when i try to access https application.

 

Can some one please help me .

 

below is the code.

var request = [];

    request.push('POST', ' ', path, ' ', "HTTP/1.1\n");       

    request.push('Authorization:', 'Basic d2NhZG1pbjp3Y2FkbWlu==', '\n');

    request.push('Host: ', host, "\r\n");

    request.push('User-Agent: ', USER_AGENT, "");

    //request.push('Connection: ', 'close', "\n");

    request.push('Pragma: ', "no-cache", "\r\n");

    request.push('Accept: ', "*/*", "\r\n");

    request.push('Accept-Charset: ', "UTF-8", "\r\n");

    request.push('Accept-Language: ', "en-US", "\r\n");

    request.push('Content-Language: ', "en-US", "\r\n");

    request.push('content-location: ', file.name, "\r\n");

    //request.push('Content-Length: ', fileContents.length, "\r\n");

    request.push('Content-Length: ', content.length, "\r\n");

    request.push('Content-Type: ', 'multipart/form-data;boundary=', boundary, "\r\n");

    

    request.push('\n');

    request.push(content);       

      alert('request--->'+request); 

    //  5. Upload

    var socket = new Socket;   

    socket.open(host+':80', 'BINARY');

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

        socket.write(request[i]);

    }

Illustrator Scripting Panel

$
0
0

Just thought I'd share an extension I've been tinkering with:

 

GitHub - majman/adobe-scripts-panel: Scripting Panel for Adobe Illustrator

 

It's a pretty simple panel that allows you to try snippets of code in the editor, list and run saved scripts from your local files, or even load and run scripts from the web.

 

Hope somebody finds it helpful. Feel free to fork the repo and send pull requests.

 

-Marshall


How to get the Selected Items X, Y position with MM value

$
0
0

Hi All,

 

In Illustrator CS5 version how to get the X, Y position in Millimeter.

 

In InDesign I can easily get the X,Y position also I can change the ruler origin easily. Illustrator I tried but I failed. Could you please any one guide me.

 

X-Y_Poition.png

 

thx,
csm_phil

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

JavaScript to prompt user to save as PDF

$
0
0

I am making changes with code to the file. I want the user to be prompted to save as a .ai file first. I have that down. Now I am wanting to have the user immediately be prompted to save as a pdf with only the optimize for fast web view option selected. I believe it is an adobe preset of Smallest File Size.

The reason for wanting the prompt is because I want to save the files in 2 different locations.

Here is my code so far.....

var doc = app.activeDocument;
// Save as .ai file  
var fileName = doc.fullName;  
var thisFile = new File(fileName);
var saveFile = thisFile.saveDlg();
doc.saveAs (saveFile);


// Save as .pdf file
var pdfSaveOptions = new PDFSaveOptions();  
pdfSaveOptions.pDFXStandard=PDFXStandard.PDFXNONE;  
pdfSaveOptions.compatibility = PDFCompatibility.ACROBAT5;  
pdfSaveOptions.preserveEditability = false;    
var pdfFile = new File(fileName);  
doc.saveAs(pdfFile, pdfSaveOptions);

AI CS4 Windows 7 64bit

PageItem.applyEffect(LiveEffectXML)

$
0
0

I am wondering if anyone has been able to figure out what kind of "LiveEffectXML" is a parameter to PageItem.applyEffect()

It's been years since this feature has been out, but no documentation anywhere.

TextFrameItem - Words - Missing Letters

$
0
0

Hellos (me again),

 

Running into an issue with words and their contents,

Say i put this in the input:

When going over the frame words as below:

var words = frame.words;  for (var i = 0; i < words.length; i++) {    var word = words[i];    alert(word.contents);
}

 

The alert with return this:

 

BUT, if i remove the '(' i get 'hello' return as it should.

 

Doing some tests, it will also remove the last letter if you add either of the following: '[', ']', '{', '}'

As it progresses through the rest of the letters, the missing letter does not appear so its as if its just randomly being removed

 

Does anyone know the reason behind these sort of characters removing the last letter of previous words and what would be a better alternative?

Viewing all 12845 articles
Browse latest View live


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