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

Is it possible to set xmp metadata to pageItems?

$
0
0

Hi All,

 

Is it possible to set xmp metadata to pageItems?

Like there is a way in photoshop to set xmp metadata to layers.


Thanks


How can I get current Mouse position via Javascript?

$
0
0

I'm trying to build a javascript tool in ExtendScript Toolkit CC to work with Illustrator CC (2015) but have run into a snag.

 

The script will create an object (a small circle in this case) at the mouse's current position within the document's active layer. But I can't seem to find a call in the library to retrieve the location info. I know that the data is tracked because if I open the "Window > Info" tool it shows the cursor's X and Y position in relation to the document bounds.

 

Is there a call anywhere in the javascript library that gives me access to these data points?

interface brightness

$
0
0

Is it possible to get information about interface brightness? Something similar to "app.generalPreferences.uiBrightnessPreference" available in Indesign.

If Action Exsits

$
0
0

I'm trying to write a script to run an action but need to make sure the action exists first.  This is what I came up with so far, and it does work when there is nothing in the prompt but if I spell the action wrong it gives me an illustrator error that the action is not there.  Should I use catch for this instead?

 

function ActionTool() {

var action = prompt('Enter Action Name', '');

var set = "MyActionSet";

 

 

    if (action == false) {

            alert("This Action does not exist.  Please try again", false);

             }

         else{ doScript( action , set ); }

}

ActionTool();

Runtime Error 429 - ActiveX Component Can't Create Object

$
0
0

Hello, I see from some web searches this is not completely new problem but I didn't find much discussion or clear solution here.

I have a lot of VBA script that references Illustrator. It has all been running good until a recent update to Windows 7 (64 Bit).

Now I get the error 429 message when the code calls Illustrator.Application.

Anyone had this same problem and managed to fix?

Any help much appreciated because this is a real headache for me!

thanks

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

How to post a question with a script inserted?

$
0
0

I see threads where the poster has included script with the line item numbers.  How does one do that?  I see nothing in the FAQ or an option to perform this?

 

thx

VBS How to select all items in a layer?

$
0
0

I wish to select all the items (PageItems?) in a layer and then set the StrokeWidth to whatever I prefer (10, 20, etc.).  When I open my .dxf file it will have two layers; 'Unknown_Area_Type' and 'Unknown_Line_Type'.  I am successful up to line 14 in the script below but after that all I could fine was a JavaScript that I was trying to convert to vbs but no luck.  Any help would be great. (please excuse for my horrible formatting  - still learning).

 

On another note, why is there no selection for VBscript when selecting Syntex Highlighting for posting code here?

 

Set App = CreateObject("Illustrator.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")

doJavaScript = "var fileRef = File.openDialog ('Select the Road DXF file to open:', '*.DXF', false); if(fileRef) filePath = fileRef.fsName;"
FileRef = App.DoJavaScript(doJavaScript)
If (FSO.FileExists(fileRef)) Then
    Set AutoCADOpenOptions = App.Preferences.AutoCADFileOptions    autoCADOpenOptions.MergeLayers = false    CurrentInteractionLevel = App.UserInteractionLevel    App.UserInteractionLevel = -1 ' aiDontDisplayAlerts    App.Open fileRef, 2 ' aiCMYK    App.UserInteractionLevel = CurrentInteractionLevel        App.ActiveDocument.Layers.GetByName( "Unknown_Area_Type" ).Delete()       Set docRef = app.activeDocument     Set layers = docRef.layers     Set myLayer = layers ("Unknown_Line_Type") ' this defines the layer that you want to get the selection from          docRef.selection = null ' ensure there is nothing in the document selected already. this way you only get the selection you want.        for(Set a=0;a<myLayer.pageItems.length;a++){ ' here we are looping through each pageItem of myLayer.          var currentItem = myLayer.pageItems[a];          currentItem.selected = true;          currentItem.selected.StrokeWidth = 20  'this is also what I wish to add    } 
End if

List missing fonts in Illustrator

$
0
0

Hi all,

 

I've been working on a script to try and build a list of font's that not loaded in Illustrator. I know that Illustrator will alert missing fonts when a document is opened but this routine will be part of a larger script that will have the user dialogs turned off. My process is to build a list of fonts that are available to the the application, then build a list of fonts that are used within the active document and cross reference them to see if there are document fonts that are not in the application fonts list.

 

I have used a great function that I believe was posted originally by Moluapple and with some some brilliant advice from the always helpful CarlosCanto I thought that I had found the soultion but it appears to have some limitations. If I get a list of fonts available to the application and the document that I want to cross reference them against is open, the list that's returned contains fonts that are used in the document. Then when I get a list of fonts used in the document and cross reference them they will all be in the application list regardless of whether they're loaded or not.

The only way that I can get accurate results are if I run the script without any documents open and build a list of application fonts, then open a document and build a list of document fonts and then cross reference. This is the only way I can find out what fonts aren't loaded.

 

Does anybody know of another way to build a list of missing fonts without having to close documents first? I have searched through the XMP data and this doesn't seem to give me any clues and I've tried writing the code in applescript but it appears to work in the same way. Any help or comments would be welcome.

 

Here's my code:

 

#target illustrator

 

 

var doclist = app.textFonts

 

 

var appFontList = new Array ();

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

    var fontName = app.textFonts[i].name;

    appFontList[i] = fontName;

    }

 

 

var myfile = File.openDialog ('Choose a file');

app.open (myfile);

 

 

var docFontsList = getUsedFonts(activeDocument);

 

 

// function accredited to Moluapple

 

 

function getUsedFonts (doc ){

     var xmlString = new XML(doc.XMPString);

     fontsInfo = xmlString.descendants("stFnt:fontName");

     var ln = fontsInfo.length(), arr = [];

     for (var i = 0; i<ln; i++){arr.push(fontsInfo[i])};

     return arr;

}

 

 

var missingFontsList = checkFonts();

alert(missingFontsList);

 

 

function checkFonts(){

    var fontArray = new Array ();

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

        var thisDocFont = docFontsList[i];

        var activeFont = false;

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

            var thisAppFont = appFontList[j];

            if (thisDocFont == thisAppFont){

                activeFont = true;

                }

            }

        if (activeFont == false){

            fontArray.push (thisDocFont);

            }

        }

    return fontArray;

    }

 

 

Many Thanks,

Nik

How create outline text of a Character in Illustrator by Script?

$
0
0

I want add a Rectangle around Characters.

With indesign : i can create outline of Characters,: ex:   Dim oaPols = oRange.CreateOutlines(False)

But with Illustrator only can create outline of TextFrame.

 

How create outline text of a Character in Illustrator by Script?

Thanks all.

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 do I find number of objects in a layer?

$
0
0

I have a document having hundreds of layers. I want to remove specific object from layers. I am iterating through all layers but I couldn't iterate through objects within a single layer to find that specific object.

 

I there a way I can iterate through all objects in layer?

or

how do I find number of objects in a layer?

 

I am going through API documents but couldn't find it.

 

Below is the code I have written,

var artLayer = undefined;        if(app.documents.length == 0)        {            app.documents.add();        }        var myDocument = app.activeDocument;        var layerCount = myDocument.layers.length;                      for (var index = layerCount - 1; index >= 0; index-- )        {            var targetLayer = myDocument.layers[index];            var layerName = new String( targetLayer.name );            if(layerName == "Colorways")            {                artLayer = myDocument.layers[index];                              //Can I iterate through objects in a layer??
//                for(var newIndex = 0; newIndex < artLayer.items.length;newIndex++)
//              {
//                    Need something like this
//                }                break;            }        }

interface brightness

$
0
0

Is it possible to get information about interface brightness? Something similar to "app.generalPreferences.uiBrightnessPreference" available in Indesign.

Extract text from illustrator for translation then replace with translated text

$
0
0

I am trying to find a way to expedite translations of our drawings.  Each drawing has a series of callouts showing what that piece of the drawing is via text.  I would need to do 100's of drawings for each book.

 

Questions:

 

1. Can I write something to batch a folder and extract the name of the file, and the text from each textbox so that when I get the translation back, I can automate the reinsertion of the translated text to its correct field (i.e. TextField1 = "Translate this" then repopulate that same exact field with "Translation")?  In order to do this I would think each text field would have to be tagged with some unique identifier so that it would know which translation goes where in the drawing.  Keep in mind, I'm ok with manually tagging each textbox if necessary.

 

2. Assuming the above is possible, what would be the best program to write the extracted text to so that reading and writing the translated text back into the drawing is as easy as possible (i.e. Word, Excel, PDF)?

Remove carriage returns and format text

$
0
0

So I have the following code that will look at a specific layer....ignore textFrames that don't have a dash in it and then create a report txt on my desktop.

#target illustrator
var doc = app.activeDocument;
var allText = doc.textFrames;
var allLayers = doc.layers;
var count = 0;
var dashFrames = new Array();


for (z = 0; z < allLayers.length; z++) {    if (allLayers[z].name == "Single Line" || allLayers[z].name == "Two Line" || allLayers[z].name == "Three Line" || allLayers[z].name == "Four Line") {        //alert("Found single two three four layer");        for (i = 0; i < allText.length; i++) {            if (allText[i].typename == "TextFrame") {                //alert(allText[i].layer);                if (allText[i].layer != "[Layer Single Line]") {                    //skip it                } else {                    if (allText[i].contents.match("-")) {                        if (allText[i].contents.substr(0, 4) == "UENR" || allText[i].contents.substr(0, 4) == "RENR" || allText[i].contents.substr(0, 4) == "SENR" || allText[i].contents.substr(0, 4) == "KENR") {                            //skip it                        } else {                            dashFrames[count] = allText[i].contents;                            count++;                        }                    }                }            }        }    }
}


var formatSerials = "";
var advanceNum = 1;
for (var i = 0; i < dashFrames.length; i++) {    if (advanceNum < dashFrames.length) {        formatSerials += dashFrames[i] + ", ";        advanceNum++;    } else {        formatSerials += dashFrames[i];    }
}


var str = '<meta name="SN Effectivity 1" content="' + formatSerials + '">\r'


var f = File("~/Desktop/" + "SN Info.txt");
f.open('w');
f.write(str);
f.close(









);

 

So the content of my txt file looks like this.......

<meta name="SN Effectivity 1" content="C18:

LNB1-UP

LZB1-UP

L8D1-UP

LXK1-UP, C15:

CE51-UP

LNA1-UP

LZA1-UP

L8B1-UP

LXJ1-UP, C13:

CE31-UP

NH31-UP

DH41-UP

NH41-UP">

 

First off it is pulling in text that doesn't have a dash (because they are part of a multiple line single text box)?

I have 3 text boxes and here is what they look like....

TEXT FRAME 1

A13:

CE31-UP

NH31-UP

DH41-UP

NH41-UP

 

TEXT FRAME 2

A15:

CE51-UP

LNA1-UP

LZA1-UP

L8B1-UP

LXJ1-UP

 

TEXT FRAME 3

A18:

LNB1-UP

LZB1-UP

L8D1-UP

LXK1-UP

 

So when all is said and done I need my txt output to look like this.....

<meta name="SN Effectivity 1" content="LNB1-UP, LZB1-UP, L8D1-UP, LXK1-UP, CE51-UP, LNA1-UP, LZA1-UP, L8B1-UP, LXJ1-UP, CE31-UP, NH31-UP, DH41-UP, NH41-UP">

 

Leave out anything without a dash.....all on one line.....separated by a comma and a space.

 

Any help would be greatly appreciated!


Illustrator scripting bug list.

$
0
0

Hello dear friends, the time has come... to assemble a list of bugs we want to have eliminated.

I've come into contact with an engineer on LinkedIn and he has this to say in a private email exchange:

 

Me: "I have a variety of issues I can provide you with, including cases provided by other scripters around the world. Would you want to focus on any specific issue at first, or do you wish to get the entire catalog of reports?"


Him: "Entire catalog in a prioritized list will be great. I can then get into a conversation with developers with this doc. Also, anything you can do to help me explain why fixing something “non obvious” is important will also help me."

 

Okay, so let's put some list together to send him and hopefully it can start some ball rolling.
I think we should come up with a format to document each "situation" , as these bugs are not typical user bugs and are sometimes more elusive.

Changing Symbols

How to open illustrator default Templates using javascript (Dialog list to Open template)

fill color using a script.

$
0
0

I'm trying to create a script in CS5 mac os10.6.8 that will change the fill color of selected pathItems. I need a simple script that will change a selected pathItem to cmyk values 2,3,15,0. I will then select this script and implement the action in a batch of 600 files.

 

I wish this process could be recorded as an action but when I record the action "add new swatch" I have to manually input the cmyk values, which will take forever for a batch of over 600 files.

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.

Viewing all 12845 articles
Browse latest View live


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