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

how to find placed or linked image mode

$
0
0

HI anyone please help me to find placed or raster image mode

 

i tried with below code but i couldn't find

 

here is my code

 

if (sel[i].typename == "PlacedItem"||"rasterItem")

                        {

                            var iplaced = sel[i];

                           iplaced.fileType = file;and iplaced.fileMODE = file;//i tried with the following code but i i oculdent get

                            alert(file);

                         }



Please ant one help me


Thanks

APPU


Querying SQL or Google Sheet from ExtendScript...

$
0
0

    Looking for a way to query JDBC databases from ExtendScript, or alternatively access data in a google spreadsheet.  I know I can import CSV but I need a solution that pulls data dynamically from a live DB.  Has anyone here attempted either of these before?

1346458189 ('MARP') Error: Unlocking layers

$
0
0

Hi all,

 

I have a script that is used to tidy up a file before it is sent out. As a part of this i need to be able to unlock layers and make them visible, i have used this sample script that I have below without problems in the past but i am suddenly getting these errors, could someone please explain why?

 

function UnlockLayers(){

   

    // Loop through the docs layers and capture the locked states of each one.
                for ( var i = 0 ; i < app.activeDocument.layers.length; i++ ) {
                        // Unlock/Unhide layers here
                        app.activeDocument.layers[i].locked = false;
                        app.activeDocument.layers[i].visible = true;

                       

                }
}


Thanks to anyone that has any suggestions,

Tom

Create a guideline

$
0
0

Is there a way to make a guideline with script that is the same as the ones you drag off the ruler?

 

The ones you drag from the ruler are the width or height of the whole pasteboard and can never be dragged away from the edges of the pasteboard.

If you create a line and turn it into a guide, it will not behave the same..

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

How do I save a .DXF file in Illustrator as an AI file using VBscript?

$
0
0

I have a VBA script that opens a .DXF file in Illustrator, and want to save it as an AI file. How do I do this?

Run a script on file open?

$
0
0

I realize there is a way to run scripts when AI launches, but is there a way to run a script when AI opens a file?

Link to a web page from AI javascript?

$
0
0

I've written a script with a ScriptUI interface, which other people will be using. I'd like to include a 'help' button in the interface, which ideally would connect to a web page with more details. (The alternative is to create the 'help' window in javascript, but the web page already exists and it would be a shame not to use it.)

 

From what I've read, other Creative Suite programs may be able to connect to the web with javascript, but apparently not Illustrator. Can anyone please confirm this is so? Or better, point me towards a solution!

 

With thanks.


Make a clipping Path while retaining it's appearance - script

$
0
0

This has been a long standing wish of mine, and I've devised this script that "kind of" works.

 

This script takes your selection, copies appearance attributes, and pastes them to the top object after clipping.

 

It's currently limited in a few ways:

• It does not accept compound paths as clipping object (and I don't know how to test for it, nor how to iterate down said compound clipping object to set each path object to clipping separately)

• It only works with a single stroke or fill

• It does not understand "no fill" it will fill your object with white instead *FIXED*

• I'm hoping to use the "graphicStyle" property to copy the appearance, since that sounds way cleaner. But I don't understand how to.

 

 

Even with these limitations, I bound this to CMD+7 using fastscripts - I'm *already* used to it working this way!

Carlos Santos, thank you for writing the base of what became this script

 

I'd be much obliged if anyone can help me out with any of those limitations / wishes.

 

#target Illustrator

//  script.name = Clip Retaining Color.jsx;
//  script.required = at least two paths selected, top most path is the clipping mask;
//  script.parent = Herman van Boeijen, www.nimbling.com // 30/11/13;
//  *** LIMITED TO A SINGLE STROKE AND/OR FILL OF THE CLIPPING OBJECT***
//  Here's hoping to use the "graphicStyles" property to copy over the appearance.


if ( app.documents.length > 0 ) {    idoc = app.activeDocument;
}else{    Window.alert("You must open at least one document.");
}


var idoc = app.activeDocument; // get active document;
var sel = idoc.selection; // get selection
var selectedobjects = sel.length;


function ClipRetainingColour(idoc){
    var lay = activeDocument.activeLayer    if(lay.locked || !lay.visible){        alert("Please select objects on an unlocked and visible layer,\nthen run this script again.");        return;    }    var igroup = lay.groupItems.add(); // add a group that will be the clipping mask group    var imask = sel[0]; // the mask is the object on top    var clipcolors = [];    //copy appearance    if(imask.filled)     {clipcolors.fillColor = imask.fillColor;}    if(imask.stroked)    {        clipcolors.stroked = imask.stroked;        clipcolors.strokeWidth = imask.strokeWidth;        clipcolors.strokeColor = imask.strokeColor;    }     for (var i = selectedobjects-1 ; i > 0 ; i--){        var ipath = sel[i];        ipath.move(igroup, ElementPlacement.PLACEATBEGINNING);    }    imask.move (igroup, ElementPlacement.PLACEATBEGINNING);       //enable clipping    igroup.clipped = true;    imask.clipping = true;    //paste appearance    if(clipcolors.fillColor)    {imask.fillColor = clipcolors.fillColor;}    if(clipcolors.stroked)      {        imask.stroked = clipcolors.stroked;        imask.strokeWidth = clipcolors.strokeWidth;        imask.strokeColor = clipcolors.strokeColor;    }
}


if (selectedobjects){
    ClipRetainingColour(idoc);
}

Does placedItems.add() take additional parameters?

$
0
0

When manually placing objects (pdf files) in Illustrator you get an option to select either bleed, trim, art, bounding box etc as the bounds of the placed document.

Can this be specified in the script? At the moment my artwork gets cropped at trim box. I would really want to use bleed to bounding box when placing items in my script.

Thanks.

file = whatever pdf I have to place.

function makeTempPDF(file){

   docRef = app.documents.add();

  newLayer = docRef.layers.add();

  thisPlacedItem = newLayer.placedItems.add();

  thisPlacedItem.file = file;

}

Can I get some value from user? (illustrator cs3 script)

$
0
0

I am Designer. But I have to write program.

 

I will making plugin about draw rectangle.

 

 

 

1. User run illustrator cs3.

 

2. User click File-Scripts-myDraw

 

3. Show dialog box. Dialog box have two inputField. User input values.(ex>53.32,   41.2)

 

4. click 'summit' button.

 

5. illustrator cs3 draw 53.32 * 41.2 size rectangle!!

 

 

 

I don't know How I made dialogbox...

 

Is it possible get value from user?

 

 

what is 'cin' code as illustrator javascript?  (cin : C++ style input code.)

 

 

please help me.

BridgeTalk Messages Inside onClick Function

$
0
0

Hello,

Is there any reason why I can't have 2 separate BT messages inside one onClick function call?  I have two BT messages, one for IA and one for Photoshop, but only one will complete.  If I either have one or the other, they work, but not both.  Do I have to prepare them in a specific way?

 

Thanks...

All Group to Ungroup Script

Dynamic image link?

$
0
0

Is there a way with JavaScript to place an image with a calculated path and file name?  I have 30+ artboards per document, each artboard named by product number.  The actual file name of the master AI file is also already established (meaning every document I use this new script on will have already been saved).

 

Here's the scenario I'm hoping to create in the context of the documents mentioned above:

Run a script to "Place" a linked image based on the following calculated path:

 

["S:\SAP\Current Images in SAP\Stock Schools\"] + [current ai filename minus the .ai extension]+[a hyphen like this "-"]+[currently selected artboard name]+[".jpg"]

 

This image link can be placed on a new top layer called "Images" or if necessary on the currently selected layer.  Dimensions of the placed image should be a pre-determined size 8"x8".

 

Error if the ai document has not been saved yet.

 

Is a script like this possible?

 

Thanks,

Tim

Selecting Symbols on page by name

$
0
0

Im struggling with the correct use of symbol / symbol items in applescript. I can successfully list the symbols used on the page, but I cannot select them. Any suggestions on how I can select all the items on the page that are Symbol Items of symbols named "Apples" but not oranges? After that I hope to replace the instances matching the height or width of the items whichever is greater with a 3rd item name. Any suggestions would be great. Javascript is always an option as well but I had the same difficulty.


Script works Great, Pro-Tips appreciated.

$
0
0

This script is used to make a few changes that SOME of our die suppliers require. It works great. If you have a little time to look it over and give me some advice on best practices, consiseness etc. it would be greatly appreciated.

 

Note: The files this script is aimed at are fairly civilized, and don't vary much so I didn't have to buld in room for varience. For example, the die lines will ALWAYS be a spot color, so I didn't need to include anything for RGB or CMYK.

 

 

// script.name = prepDieFile.js;
// script.description = removes unnecessary layers, vectors, and text. Leaves cross-mark line unpainted. Colors all remaining text and strokes black;
// script.requirements = an opened document;
// script.parent = elDudereno // 10/10/13;
// script.elegant = false;


#target Illustrator


var idoc = app.activeDocument;
var pi = idoc.pathItems;
var tf = idoc.textFrames;
var deletedLayers = 0;
var deletedPaths = 0;
var spotStroke = 0;
var deletedText = 0;
var blackedText = 0;


var layerCount = idoc.layers.length;
//loop through all layers deleting hidden layers. Loop from the back, to preserve index of remaining layers when we remove one.
for (var i = layerCount - 1; i >= 0; i--) {          var thisLayer = idoc.layers[i];          if (thisLayer.visible == false || thisLayer.locked == true) {                    thisLayer.visible = true;                    thisLayer.locked = false;                    thisLayer.remove();                    deletedLayers++;          }
}


unlockPaths();


//locate largest path item (bounding box) and lock it.
var theBiggest = pi[0];
for (i=1; i<pi.length; i++) {          if (Math.abs(pi[i].area) > Math.abs(theBiggest.area)) {                    theBiggest = pi[i];          }
}
theBiggest.remove();
deletedLayers++;
//locate second largest path (cross-mark size) remove stroke and lock
var secondBiggest = pi[0];
for (j=1; j<pi.length; j++) {          if (Math.abs(pi[j].area) > Math.abs(secondBiggest.area)) {                    secondBiggest = pi[j];          }
}
secondBiggest.strokeColor = NoColor;
secondBiggest.fillColor = NoColor;
secondBiggest.locked = true;


// loop through path items delete if hidden, registration, or un-stroked. Change all non-registration spot colors to 100% GrayColor.
for (var j=pi.length -1; j >= 0; j--) {          var ipath = pi[j];          if (ipath.hidden==true) {                    ipath.remove();                    deletedPaths++;          }          if (ipath.locked==false) {                    var strokeColor = ipath.strokeColor;                    if (strokeColor.typename == "NoColor"){                              ipath.remove();                              deletedPaths++;                    }                    else if (strokeColor.typename == "SpotColor"){                              if (strokeColor.spot.name == "[Registration]"){                                        ipath.remove();                                        deletedPaths++;                              } else {                                        ipath.strokeColor = GrayColor;                                        ipath.strokeColor.gray = 100.0;                                        spotStroke++;                              }                    }          }
}
unlockPaths();


// delete text frames with first letter set to registration. Turn all other text to black.
for (t=tf.length -1; t>=0; t--) {          var iTxtFrm = tf[t];          var firstLtr = iTxtFrm.characters[0];          if (firstLtr.characterAttributes.fillColor.spot.name == "[Registration]"){                    iTxtFrm.remove();                    deletedText++;          }          else {                    var chars = iTxtFrm.characters;                    for (var c=0; c<chars.length; c++) {                              var ltr = chars[c];                              ltr.characterAttributes.fillColor = GrayColor;                              ltr.characterAttributes.fillColor.gray = 100.0;                              blackedText++;                    }          }
}


redraw();


alert(deletedLayers + " hidden or locked layer(s), " + deletedPaths + " path(s) & " + deletedText + " text frames, were deleted.  " + blackedText + " letters, & " + spotStroke + " stroke(s) were converted to 100% K.");


//unlock all path items
function unlockPaths(){
          for (var k=0; k<pi.length; k++){                    var lpath = pi[k];                    if (lpath.locked == true){                              lpath.locked = false;                    }          }
}

 

Thanks for taking a look.

 

http://www.filedropper.com/0388701die<-sample file.

UI (Window, dialog, palette etc) reference info for AI scripting

$
0
0

I'm looking for standard reference info on UI elements like popup windows (dialogs, palettes etc). I've been through the Illustrator CS6 Javascript Scripting reference guide and also the CS6 Scripting guide, checking every mention of the words "Window", "Dialog", "Palette" etc (there aren't many), plus related terms like "edittext" and "slider" (which seemingly don't exist in these documents at all), and can't find what I'm looking for.

 

----------

 

I'm trying to script a simple info box that contains information generated by a script that doesn't need to be closed before the user continues working.

 

All I'm trying to find out is the basics. From looking at other scripts I've figured out that you can create a popup box like this:

 

var box = new Window('dialog', 'Some title');

var panel = box.add(panel, undefined, 'Panel title');
panel.add('edittext', undefined, 'Default value');
panel.add('slider', undefined, /*Default numeric value*/,/*min*/,/*max*/);

var group = box.add(group, undefined, 'Group title');
group = area_len_box.add('group', undefined, 'Title (not displayed)');
group.orientation='row';
group.closeBtn = group.add('button',undefined, 'Close', {name:'close'});
group.closeBtn.onClick = function(){
  box.hide();  return false;
}

...which is enough for a very rudimentary input system, but one which has to be closed before the user can return to their work - and I can't find any resource that gives the full options:

 

  • What are the other options for 'new Window'? I'm aware of 'palette' which appears to need an array of four co-ordinates like [20,20,100,100], but it clearly needs something else too as every palette I've made instantly closes. And what else is there beyond Window and Palette?
  • What other input devices are there beyond edittext and slider, and what parameters do they each need?
  • What can go in the "undefined"s I see everywhere these are used?
  • etc etc

 

There must be a reference to this somewhere, but I can't find it.

Link to a web page from AI javascript?

$
0
0

I've written a script with a ScriptUI interface, which other people will be using. I'd like to include a 'help' button in the interface, which ideally would connect to a web page with more details. (The alternative is to create the 'help' window in javascript, but the web page already exists and it would be a shame not to use it.)

 

From what I've read, other Creative Suite programs may be able to connect to the web with javascript, but apparently not Illustrator. Can anyone please confirm this is so? Or better, point me towards a solution!

 

With thanks.

[JS] CS6+ executeMenuCommand

$
0
0

Hello together,

 

since CS6+ there is possible to

executeMenuCommand (menuCommandString: string)

Executes a menu command using the menu shortcut string.

 

Question 1:

Who knows a way to read all the available commands?

 

Question 2:

At the time I need 'Clear Guides'

 

app.executeMenuCommand ('Clear Guides')

app.executeMenuCommand ('Clear guides')

app.executeMenuCommand ('clear Guides')

app.executeMenuCommand ('ClearGuides')

app.executeMenuCommand ('clear guides')

 

and other variants doesn't work.

 

Who know the right syntax? (Or is this menu command not available????)

 

 

Any help is appreciated. (Additional: I know the way to use app.doScript (myAction) - but this is not part of my questions)

Batch combine files into one illustrator document - how to open target document?

$
0
0

I am making a script which will:

 

1) Open a folder of Illustrator files

2) Open each file in the folder (these files are called the source files)

3) Select all the contents of the source file

4) Copy the contents of the source file

5) Paste these contents into a target file as a new layer

6) Ensure the new layer has the same name as the old source file

 

 

However, I don't know how to tell Illustrator where my target file is. How can I do this?

 

Also, when I paste, how can I turn off paste rembers layers. (So the layers get pasted into the new layer that has the same name as the old document).

 

Here is my code:

 

 

// JavaScript Document

 

 

//Set up vairaibles

var destDoc, sourceDoc, sourceFolder;

 

 

// Select the source folder.

sourceFolder = Folder.selectDialog('Select the folder with Illustrator files that you want to mere into one', '~');

 

 

// If a valid folder is selected

if (sourceFolder != null) {

          files = new Array();

 

 

          // Get all files matching the pattern

          files = sourceFolder.getFiles();

 

 

          if (files.length > 0) {

                    // Get the destination to save the files

                    destDoc = document.selectDialog('Select the final saved document', '~');

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

                              sourceDoc = app.open(files[i]); // returns the document object

 

                              var myLayers = sourceDoc.layers; // All layers in Active Document

 

 

                              //Go through all layers of source document and copy artwork

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

                                        myLayers[i].hasSelectedArtwork = true;

                              };

 

 

                              with(sourceDoc) {

                                        var count = pageItems.length;

                                        for (var i = 0; i < count; i++) {

                                                  pageItems[i].selected = true;

                                        }

                                        redraw();

                                        copy();

                                        for (var i = 0; i < count; i++) {

                                                  pageItems[i].selected = false;

                                        }

 

 

                              }

 

 

                              //Create a new title variable that has the title of the source document

                              var title = sourceDoc.name;

                              var title = title.substring(0, title.length - 4); //(remove extension from name)

                              //Close the Source Document

                              sourceDoc.close(SaveOptions.DONOTSAVECHANGES);

 

 

 

 

                              //Open the Destination Document and create a new layer in it that is named after the title variation

                              var newLayer = destDoc.layers.add();

                              newLayer.name = title;

 

 

                              //Paste into this new layer

                              destDoc = app.paste();

 

 

                    }

          }

          else {

                    alert('No matching files found');

          }

 

}

 

Thanks in advance for any help   

 

Edit: Also, when pasting, how can I paste in place instead of just pasting.

Viewing all 12845 articles
Browse latest View live


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