Quantcast
Channel: Adobe Community : Discussion List - Illustrator Scripting
Viewing all 3671 articles
Browse latest View live

Is this type script possible, or previously existing?

$
0
0

Hi there. So I wanted to import a raster image, specifically pixel art, DIRECTLY into Illustrator, converting each pixel of the raster to a vector square. Now I can manually recreate a pixelized image this way, but that takes forever. I have no desire to use the livetrace or fuss with touch-ups when assembling vector squares is exact. Each pixel is a fixed point of information though in the image, so surely those smallest units of visual information could be straight-on converted. A square is a square, it's not changing shape. It doesn't seem complicated for the computer to read the image and simply reproduce it in vector squares with the proper commands.


Unfortunately, I haven't found any sort of script existing that accomplishes this, and the methods I see touted in youtube videos on the subject are inexact and require touch-up. I want each block as a separate shape as well. I'd rather use manual reproduction, but it's time-consuming and I shouldn't have to re-do a bunch of work.

 

Is the sort of script I'm looking for something that currently exists already, or even possible? Cubic reproduction based on each pixel would be the simplest way to convert any Raster image directly into a Vector format, without having to have it traced and re-rendered, if smooth lines aren't your desire. I'm using CS5 by the way.

 

Thanks very much. I appreciate the knowledge & insight.


What is the FASTEST way to identify colors used on a layer?

$
0
0

Hi All,

 

Is there any "faster" way to identify colors used on a given layer other than to iterate through the layer's pageitems?  I am optimizing a few scripts and am looking to squeeze milliseconds as a layer with a lot of pageitems can take a while (relatively speaking of course). :-)  Any perspectives would be appreciated.

 

All the best!!

 

-TT

Javascript - Place text files

$
0
0

Hi,

 

I have multiple text documents in .TXT, .RTF, and .DOCX. Please advise how to place them using Javascript. Manually, I can place those file, but looking for Javascript solution.

 

Thanks in advance.

Is there a script available for arranging elements for optimal use of the printable area?

$
0
0

I'm starting a sticker printing business using Illustrator as my main layout and illustration too. I was wondering if there's a script available for automatically arranging a set of elements on a page so that they optimally take up the available space. I figured this would save me some on material costs.

 

If I were to create a script from scratch, can someone give me pointers? I'm a casual AI user but I have Javascript experience.

 

Thanks.

Startup Script for Illustrator only

$
0
0

Hi,

 

I've made a nice palette script for Illustrator CS6 on OSX 10.6.8.

I put it into HD/Library/Application\ Support/Adobe/Startup\ Scripts\ CS6/Illustrator

 

I works fine in Illustrator.

 

BUT: If I start Indesign CS6, the palette show up twice and it is not possible to close both pallettes.

 

Any hints?

 

Next question: The palette is used to have an easy access to script. If I start the scripts with the palette, the error messages of the scripts are not displayed. If I start individal script directly in Illustrator errors are displayed. What can I do?

 

Thanks for your help.

 

 

 #target illustrator;

#targetengine main;

//var pfad = "/Applications/Adobe\ Illustrator\ CS6/Presets.localized/de_DE/Skripten/"
var pfad = "/Volumes/Platte/Hilfsmittel/Skripte/"

var win = new Window('palette', 'Daniels Zauberkiste');
var tpanel = win.add ("tabbedpanel");
tpanel.alignChildren = ["fill", "fill"];
tpanel.preferredSize = [100,20];
win.margins = 0;
win.spacing = 0;
var subtab1panel = tpanel.add ("tab", undefined, "allgemein");
subtab1panel.orientation="row";
subtab1panel.alignChildren = ["fill", "fill"];


var t1group = subtab1panel.add("group");
t1group.orientation = "column";
t1group.alignChildren = ["fill", "fill"];


var btnSelect1 = t1group.add('button', undefined, 'Passer');
var scriptToLoad1 = new File(pfad+"_Passer-Montage.jsx");
var btnSelect2 = t1group.add('button', undefined, 'Prüfpasser');
var scriptToLoad2 = new File(pfad+"_Prüfpasser-Montage.jsx");
var btnSelect3 = t1group.add('button', undefined, 'Kontur+10');
var scriptToLoad3 = new File(pfad+"_Kontur+Dok+10.jsx");
var btnSelect4 = t1group.add('button', undefined, 'Kontur+20');
var scriptToLoad4 = new File(pfad+"_Kontur+Dok+20.jsx");
var btnSelect5 = t1group.add('button', undefined, 'Standardbogen Stanze');
var scriptToLoad5 = new File(pfad+"_Bogengröße.jsx");


btnSelect1.onClick = function(){
      var des = scriptToLoad1;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();  
}// end function


btnSelect2.onClick = function(){
      var des = scriptToLoad2;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send(); 
}// end function


btnSelect3.onClick = function(){
      var des = scriptToLoad3;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function


btnSelect4.onClick = function(){
      var des = scriptToLoad4;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function


btnSelect5.onClick = function(){
      var des = scriptToLoad5;   des.open("r");         var bt = new BridgeTalk;   bt.target = "illustrator";         var script = des.read();   des.close();              bt.body = script;   bt.send();
}// end function










win.center();
win.show();

Remove namespaces from elements

$
0
0

There is a problem I am experiencing, that others have discussed here Illustrator retains unsavory namespaces in SVGs, can't open it's own export

 

Basically the AI document retains namespace data from SVG's that have been copied or used in some way to create the AI.

 

When the document is saved to SVG - these namespace references remain and can result in invalid SVG output.

 

Does anyone know of a way that these namespaces could be accessed using Illustrator Scripting?

 

thanks,

 

Mochael

Changing color from Swatch to Spot color

$
0
0

Hello,

I have almsot figured this out but have on hangup.  I am trying to replace a color with another color from a Pantone library. I am using Illustrator CS6.

I have this script which I found on here:

 

#target illustrator

 

var docRef = app.activeDocument;

 

with (docRef) {

 

var replaceColor = swatches.getByName('Pantone 152 C').color;

 

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

with (pathItems[i]) {

if (filled == true && fillColor instanceof SpotColor) {

if (fillColor.spot.name == '  HCS Orange') fillColor = replaceColor;

}

}

}

 

for (var j = 0; j < stories.length; j++) {

with (stories[j]) {

for (var k = 0; k < characters.length; k++) {

with (characters[k].characterAttributes) {

if (fillColor instanceof SpotColor) {

if (fillColor.spot.name == '  HCS Orange') fillColor = replaceColor;

}

if (strokeColor instanceof SpotColor) {

if (strokeColor.spot.name == '  HCS Orange') strokeColor = replaceColor;

}

}

}

}

}

}

 

Which works,  but only if the new PMS color is added to the swatch list.  It seems I cannot get the swatch in the list easily using a script(which I have no experience with) or using an action.  Nor can I change the name after var replacecolor as it seems to only look for the swatch panel and not the color group or color book panel

 

Any suggestions would be helpful, I am looking at having to change 30,000 files.

 

Thanks,

Matt

Help!I have a script to export layers to jpg one by one, but I need to access the "use artboard" option

$
0
0

I want the exported pictures to use the artboard's size. Thanks in advance.

 

var folder = Folder.selectDialog();
var document = app.activeDocument;
if(document && folder)
{       var options = new ExportOptionsJPEG();    options.antiAliasing = true;     options.qualitySetting = 100;       options.optimization = true;    options.croppingMaskClipping = true;            //scale to 500dpi    options.verticalScale = 500;    options.horizontalScale = 500;        var n = document.layers.length;    for(var i=0; i<n; ++i) {        hideAllLayers();        var layer = document.layers[i];        layer.visible = true;        var file = new File(folder.fsName+"/"+layer.name+".jpg");        document.exportFile(file,ExportType.JPEG,options);    }    //to show all layers visible when done:    showAllLayers();
}

function hideAllLayers()
{
    forEach(document.layers, function(layer) {         /**         if there is one or more layers called 'ABC' in the .ai file, it will always be part of the export.        */        if( layer.name != "ABC"){            layer.visible = false;        }    });
}



function showAllLayers()
{
    forEach(document.layers, function(layer) {            layer.visible = true;     });       
}


function forEach(collection, fn)
{
    var n = collection.length;    for(var i=0; i<n; ++i)    {        fn(collection[i]);    }
}

Read input parameters from a script file name

$
0
0

I asked this in the main Illustrator forum an hour ago, but then realized that there was a separate forum for script questions…so please forgive the repetition.  I am sure this is a newbie adobe javascript question, but I have looked for some time and cannot figure out the answer. How do I read input parameters from a script file name? For example, let’s say I want to run a script that requires 3 variables as input, but rather than prompting for the values I wish to read them from the script file name … e.g., the file name might be “Myscript.js (my_variable1, my_variable2, my_variable2)” … where variables are all real numbers. So I assume the script name when run should look something like …  Myscript.js (10, 10, 100), but how do I then read these and assign these values to a var statement within the script?

Script Panel - Work in progress

$
0
0

Hi All,

Working on a Script Panel to make scripts simpler to run in illustrator.

This is a work in progress...

Untitled-3-01.jpg

 

Looking for some people to help test and make suggestions.

 

at the moment this is a Windows only program... Sorry Mac users

and right now it is still an AHK file.

 

so I'm looking for people who already use AHK (AutoHotKey)

 

both files need to be saved in the same directory. would be best if they had their own folder.

Settings file needs to be manually updated at this point and will need the path to your desired script folder and the path to your illustrator updated for it to work.


once AHK file is running it will scan the script folder for scripts.

will also scan sub folders but only 1 deep, this way groups of scripts can be organized.

Window will appear center screen, just drag the panel to where you want it.

so far you can mouse click any script to run it.

it is also tied to the "Tilde" or "Back Tick" / "~" or "`" no shift needed.

This will make the window active and allow you keyboard access to the scripts. ie. "Tilde 24 Enter" will run script 24


I have plans for settings window so any variable such as paths, font etc. can be set from the program.

And also will make the sub folders collapsible for simpler viewing.


Can't wait for thoughts and suggestions.


http://qwertyfly.com/files/Script%20Menu/





search a word between "( )" and apply CharacterStyle

$
0
0

sorry my bad english

 

I need your help,

 

I can search within a parenthesis with \((.*)\)

 

ex:  hello (world) bye, need apply a CharacterStyle to "(world)" with  CharacterStyle


hello (world) bye

 

similar script:

 


var active_doc = app.activeDocument;  
var search_string = /\((.*)\)/ig; 
var text_frames = active_doc.textFrames; 


var italicStyle = active_doc.characterStyles["italica"]; 


if (text_frames.length > 0) 
{     for (var i = 0 ; i < text_frames.length; i++)       {           var this_text_frame = text_frames[i];     italicStyle.applyTo(this_text_frame.textRange);                        if (new_string != this_text_frame.contents)                {                     this_text_frame.contents = new_string;                }       } 
} 

 

 

thanks, sorry my bad english I speak spanish

Javascript to save as template file in predetermined directory with prompt for filename.

$
0
0

I've seen a bunch of examples of how to save a regular illustrator file, but I can't seem to find the syntax for saving a file as a .ait file? Am i just missing something incredibly obvious here?? I know this is not right at all.. but this is what i was able to piece together from others' questions.. But i don't see where or how it calls out what kind of file it's saving..?

 

anyone care to explain the logic in the newName variable? i copied that directly from another post (and edited the file name at the end). What does "/ARTE\..{2,4}$/i" even mean?

 

I'd also like to suppress dialogs while saving as well.

 

thanks all.

 

var sourceName = app.activeDocument.name;
var dest = ('/Volumes/customization/library/cads/');


function saveAsTemplate(destination){
    if(app.documents.length > 0){        var docRef = app.activeDocument;        var cadNumber = prompt("What's the number of this CAD?");        var newName = (sourceName.replace (/ARTE\..{2,4}$/i,'FD-SLOW-SS-' + cadNumber +'.ait');        var AIT = new File(destination);        docRef.saveAs(AIT);    }
} //end function


saveAsTemplate(dest);

Export from eps to jpg. Need to know jpg pixel dimensions.

$
0
0

i have a script which export eps to jpg using below script (width is always 1276 px). Is there any way to know the dimension of the each jpg files as an alert?

 

#target illustrator
var i,  files, sourceDoc, targetFile;

files = File.openDialog ("Hi, Please select EPS file(s)", /.eps$/, true);

try
{
if (files.length > 0)
{
  for ( i = 0; i < files.length; i++ )
  {
        sourceDoc = app.open(files[i]);
        var myVisibleBounds = sourceDoc.visibleBounds;
        myVisibleBounds[0] = myVisibleBounds[0] - 1;  // left
        myVisibleBounds[1] = myVisibleBounds[1] + 0.5;   // top
        myVisibleBounds[2] = myVisibleBounds[2] + 1;   // right
        myVisibleBounds[3] = myVisibleBounds[3] - 1 ;    // bottom

        sourceDoc.artboards[0].artboardRect = myVisibleBounds;

//        var docLeft = sourceDoc.artboards[0].artboardRect[0] - 50;
//        var docTop = sourceDoc.artboards[0].artboardRect[1] + 50;
//        var docRight = sourceDoc.artboards[0].artboardRect[2] + 50 ;
//        var docBottom = sourceDoc.artboards[0].artboardRect[3] -50 ;

        var sourceDocWidth = Math.round(myVisibleBounds[2] - myVisibleBounds[0]);

//        var sourceDocHeight = docTop - docBottom;

        var myZoom = (1276/sourceDocWidth) * 100;
//        alert(sourceDocWidth + " Math round: " + Math.round(sourceDocWidth) + "   " + myZoom);

        targetFile = getNewName();
   // Call function getPDFOptions get the PDFSaveOptions for the files
        exportOptions = exportJPEG( );
   // Save as pdf
   sourceDoc.exportFile (targetFile, ExportType.JPEG, exportOptions);
   sourceDoc.close(SaveOptions.DONOTSAVECHANGES);
     }
  alert( "Done" );
       
}
}
catch(e)
{
    alert(e +  "\r" + "No files selected");
};

 

function getNewName()
{
var ext, docName, newName, saveInFile, docName;
docName = sourceDoc.name;
//ext = '.pdf'; // new extension for pdf file
newName = "";
 
for ( var i = 0 ; docName[i] != "." ; i++ )
{
        newName = newName + docName[i];
}
newName = newName;
saveInFile = new File(sourceDoc.path + '/' + newName );

    return saveInFile;
}

 

function exportJPEG()
{
    var exportOptions = new ExportOptionsJPEG();
    exportOptions.artBoardClipping = true;
    exportOptions.antiAliasing = false;
    exportOptions.qualitySetting = 100;
    exportOptions.horizontalScale = myZoom;
    exportOptions.verticalScale   = myZoom;
//    exportOptions.transparency = false;
//exportOptions.saveAsHTML = true;
   
    return exportOptions;
       
}

ScriptUI window.minimized = true; on Mac

$
0
0

I would like to make custom palettes for Illustrator which have the ability to get out of the way, similar to native palettes.  On Windows, my minimized = true; command works, and the palette shrinks into a tiny bar, which I like.  However, same command on Mac does not do the trick.

 

#target illustrator
#targetengine main
function myPanel(){    var arr = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];    function paletteWindow(){        var w = new Window('palette', 'My Panel', undefined, {resizeable: true});        var g1 = w.add('group');        var t = g1.add('treeview', undefined, []);   t.size = [200, 450];        for(var i=0; i<arr.length; i++){            var item = arr[i];            var n = t.add('node', item);        }        t.onDoubleClick = function(){            if(t.selection != null && t.selection.text != ''){                alert(t.selection.text);            }        };        var btn_min = w.add('button', undefined, 'Minimize');        btn_min.onClick = function(){            w.minimized = true;            w.update();        }        w.onResizing = w.onResize = function () {this.layout.resize ();}        w.onShow = function(){            w.minimumSize.width = 220;            w.minimumSize.height = 100;            t.items[1].expanded = true;        }        this.show = function(){w.show();}    }    var thisPaletteWindow = new paletteWindow(); // have to call it like this, or it disappears.    thisPaletteWindow.show();
}


myPanel();

Why does my Illustrator or photoshop are not want to open on my MacBook Pro now that I installed the new Yosemite operating system?

$
0
0

I downloaded the new Yosemite operating system on my MacBook Pro last night and this morning my straighter does not want to open. When I click on the icon to open it gives me an air message sending me to download a legacy format of Java generation SE and when I do you download and install it, even after refreshing the. MacBook several times I still don't get any positive results as far as having the software open. Does somebody know why and what I can do so that I can run my existing programs from Adobe with my new Apple Yosemite operating system. I am drowning here


Open script in ESTK by using a script.

$
0
0

I am trying to make a command to open a chosen .jsx file inside the ESTK.  I was trying to make an applescript string to be written and immediately executed with file.execute() (.scpt extension), but my file.execute() just opens the string up in an applescript editor, which I can compile and run from the editor and the script does work (sort of*).  *meaning, it pops up the trust dialog if there's a #target illustrator in the document.

 

Anyways, I was looking to do the exact same thing as a Windows counterpart which I've already tested, where a .vbs file constructed thus, would work exactly as desired, opening up a .jsx file in the ESTK by doing a shell script object command in the .vbs.

How to extract images from adobe illustrator using extended javascript

$
0
0

hi,

I am working on adobe extended javascript , and I need to extract all the images from artboard(adobe illustrator).and save co-ordinates of the images in the artboard to a text file.

Thanks

Grouped Items to individual pages?

$
0
0

Is there a way to look at the group items and move them to individual pages based on their size?

 

My goal is to select for example 3 grouped items.

 

Check the width and height to see if a landscape or portrait file should be opened. Then place the group on the correct file.

Group 1: 5" wide x 9" tall

Open the file

C:/Master Templates/8.5x11 Portrait.ait

Because the group is taller than it is wide

Put Group 1 on that page

 

Group 2: 6.5" wide x 8" tall

Open the file

C:/Master Templates/8.5x11 Portrait.ait

Because the group is taller than it is wide

Put Group 2 on that page

 

Group 3: 12" wide x 9.25" tall

Open the file

C:/Master Templates/8.5x11 Landscape.ait

Because the group is wider than it is tall

Put Group 3 on that page

 

Windows 7 64-Bit CS4

 

Thanks!

Find all transparent objects

$
0
0

I am using an applescript to do anything I may miss before sending my files to the prepress department. Right now my script outlines all text (except item/batch numbers) and embeds any links. One other thing I really need to add is a simple alert if there are any transparent objects in the file. The file will be an illustrator PDF that may contain unflattened TIFF's and/or vector items with transparencies. Normally I check that a file has no transparencies using the flattener preview palette but I want a backup in case I miss/forget to check a file. I can't find any applescript or javascript code that has to do with checking for transparencies. Any scripting code using illustrator or image events to just notify about a transparency would be awesome. Thanks!

duplicating multiple groups?

$
0
0

Hello all,

 

I am attempting to develop a script where i have a selection of a group and it would duplicate twice along the x axis.  Then, take all the grouped items and duplicate it down the y axis 3x. 
This is what i have so far:

 

 

 

var myDoc = app.activeDocument;

var myNeckLabel = myDoc.selection[0];

 

// For loop duplicating selection, moving to the left 2x

for (var sel=0; sel<[2]; sel++){

  myNeckLabel.duplicate();

  myNeckLabel.translate(-3.9327*72);

}

 

// For loop duplicate selection down 3x

for (var sel=0; sel<[3]; sel++){

  myNeckLabel.duplicate();

  myNeckLabel.translate(0,-3.153*72);

}

 

 

What the above produced for me is the desired effect, except it will only do it down the left column, so i would have the top row and the left column filled out. how do i select every object the first loop creates and then feed it into the second loop?
Thanks for the help in advance !

Viewing all 3671 articles
Browse latest View live


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