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

Ungroup previous created groups

$
0
0

Hi,

 

For a new script I group all objects within layers before processing them. After processing I like to ungroup these objects again. Making the groups is not the problem and works fine, however I can't figure out how to ungroup them again.

 

So what I need is a function (script example) that uses a documentname and layername for input. That layer only contains one group and that group needs to be ungrouped to its original objects (text, paths, groups, etc.).

function ungroup( documentid, layerid ) 

  {

 

   // some code to ungroup a single group in this document and layer

 

  }

 

 

Any help is appreciated

Michel.


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

Precisely drop item from extension to AI document

$
0
0

HI,

 

I am using Illustrator version CC2015 (19.1) and mac Yosemite 10.10.3.

I have created one extension having colors swatches. When user drag a color from extension to AI document, I am creating rectangle and filling it with dragged color. This gives effect of dragging a color from extension panel to document.


So here is the deal, I can get this thing working but the location at which I am creating rectangle is not precisely where user has dropped color rectangle.


Extendscript code goes here,



 

var myDocument = app.activeDocument;         var artLayer = myDocument.layers.add();         var group = artLayer.groupItems.add();         var rect = group.pathItems.rectangle( 50, 50, 50, 50);         var x2=myDocument.activeView.bounds[0];         var y2=myDocument.activeView.bounds[1];         var zoom = myDocument.activeView.zoom;         var  y = ((dragDetails.mousePosition.mouseY/zoom)- 100/zoom); // mouseY  = event.screenY (event is drop event)         var  x = ((dragDetails.mousePosition.mouseX/zoom)- 95/zoom);  // mouseX  = event.screenX (event is drop event)         var newRGBColor = new RGBColor();         newRGBColor.red = dragDetails.RGBColor.Red;         newRGBColor.green = dragDetails.RGBColor.Green;         newRGBColor.blue = dragDetails.RGBColor.Blue;         rect.fillColor = newRGBColor; 

 

Note line no 9 and 10.

This works fine on windows. But on mac I am not getting exact X and Y co-ordinates.

When I debugged further I came to know this strange thing -

 

drag end co-ordinates = drag start co-ordinates

 

i.e. event.screenX of drag start event = event.screenX of drag end event.

     event.screenY of drag start event = event.screenY of drag end event.

 

Ideally I should get x and y co-ordinates diffrent for dragstart and dragend event. Seems a bug in cep.

 

Please help. I am badly stuck.

Set stroke color only to selected compound paths

$
0
0

Hello!

I am looking for script to set stroke color at selected compound paths (For CS6  )

Thanks!

Drawing a rectangle of exact size of the artboard?

$
0
0

Has anybody written a JS script to to draw a rectangle on an active document which would be exact size as the document's artboard?

I find it very inaccurate and cumbersome trying to draw such rectangle by hand.

 

Please let me know where such JS code can be found. I have not done any Illustrator scripting beyond the "Hello world".

 

Thanks

franK

Create a report or log file

$
0
0
#target illustrator
var doc = app.activeDocument;
var allText = doc.textFrames;
var boldText = app.textFonts.getByName("Arial-Black")


var d = new Date();
var currentYear = d.getFullYear();
var currentMonth = ("0"+(d.getMonth()+1)).slice(-2);
var currentDay = ("0" + (d.getDate())).slice(-2)


for (var i = 0; i < allText.length; i++) {    //alert(allText[i].contents.substr(0,4));    if (allText[i].contents == "Electrical System") {        //alert("This is an Electrical Schematic");        var mediaType = allText[i].contents;    }    if (allText[i].contents.substr(0, 4) == "UENR") {        //alert("Media Number " + allText[i].contents);        var mediaNumber = allText[i].contents;    }    var textFieldRange = allText[i].textRange;    var textProps = textFieldRange.characterAttributes;    if (allText[i].contents != "Electrical System" && textProps.textFont == "[TextFont Arial-Black]") {        //alert("Your Title is: " + allText[i].contents);        var mediaTitle = allText[i].contents;    }
}


var emailAddress = "someone@myemail.com";
var dateFormat = currentYear + "" + currentMonth + "" + currentDay;


//alert("Media #: " + mediaNumber + "\nMedia Type: " + mediaType + "\nTitle: " + mediaTitle + "\nEmail report to: " + emailAddress + "\nSubmitted on: " + dateFormat);










 

So I am wanting to take the information from the above script I wrote and have a text file of sorts in a certain format. For example I would like this format

<meta name="Internet E-Mail Address" content="emailAddress">

<meta name="Media No Rev" content="mediaNumber">

<meta name="Publication Date" content="dateFormat">

 

so a finished report would look like this for example:

 

<meta name="Internet E-Mail Address" content="someone@myemail.com">

<meta name="Media No Rev" content="UENR1234">

<meta name="Publication Date" content="20160226">

Looking for solution to read/write Excel data...

$
0
0

   I've been using CSV to import excel data into AI - but I need to be able to import and export the excel data directly, without using ActiveX, direct reads and writes to the XLS file.  This is because CSV loses the formatting and I need to retain that.  Does anyone know of a third party javascript library for working with excel files?

 

   I've also thought of using Excel XML instead of the typical excel format as this will retain the formatting.  However, I know nothing about XML so if there is likewise an easy way to read/write excel XML files or a library somewhere for this, please let me know.

Adjust dashes to corner and path ends InDesign CC 2015

$
0
0

Hello,

 

I am using Illustrator CC 2015.1.0 with Scripting. I have dashed lines in my drawing and want to align dashes to corners and path ends.

No problem in the Illustrator stroke menu. There are two buttons with dashed lines on it. There I can select this option:

dashes.jpg

 

Since I cannot find the script command to do this, I use this script

s.h's page : Adjust Dashes

 

But this script does no longer work in CC 2015.1.0. So what can I do?

Is the option in InDesign now available as script command?

Or has someone an update of the script?

 

Best regards

 

Harald


Reworking Photoshop layer renaming script for Illustrator

$
0
0

The Photoshop scripting guru Paul R over at RetouchPro has created a really cool script to batch rename and number selected Photoshop layers. I haven't found anything similar on the Illustrator side.

 

He's given permission for me to post it here in my hopes that some Illustrator scripting genius could come up with a similar script for Illustrator. Would it be terribly difficult to convert this into something Illustrator could use?

 

http://www.mediafire.com/file/g7usr73u0236p0a/Rename_&_Renumber_Selected_Layers.jsx

 

http://www.mediafire.com/file/dbah74x13bsa74c/Rename_&_Renumber_Selected_Layers.jsx.zip

 

rename-layers.png

Batching In Illustrator??

$
0
0

In PhotoShop CS3, you can select File/Automate/Batch, and run an Action on an entire folder.  I don't see that option in Illustrator CS3?  Is there a way to run an action on an entire folder?

 

I'm attempting to save many EPS images as PNG images, and would really like to retain "vector attributes" - is any of this possible???

 

Thanks for any help.

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

Applescript - Its not work well (can any one help me)

$
0
0

set OrderNo to text returned of (display dialog "OrderNo:" default answer "60000")
set CustomerPO to text returned of (display dialog "CustomerPO:" default answer "TBD")
set GarmentColor to text returned of (display dialog "GarmentColor" default answer "ASH GRAY")
set GarmentDescription to text returned of (display dialog "GarmentDescription" default answer "T-Shirt")
set DesignID to text returned of (display dialog "DesignID" default answer "TBD")
set DesignTitle to text returned of (display dialog "DesignTitle" default answer "TBD")
set Location to text returned of (display dialog "Location" default answer "TBD")
set InkColors1 to text returned of (display dialog "InkColors" default answer "WH")

tell application "Adobe Illustrator"
activate
end tell

on replace_chars(this_text, "AAA", OrderNo)
{this_text, "BBB", CustomerPO}
{this_text, "CCC", GarmentColor}
{this_text, "DDD", GarmentDescription}
{this_text, "EEE", DesignID}
{this_text, "FFF", DesignTitle}
{this_text, "GGG", Location}
{this_text, "HH", InkColors1}
t
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars

Rasterize each sublayer

$
0
0

Having an issue with rasterizing in a loop.  I want to select a layer by name then rasterize each sublayer separately. I got the rasterization down but looping it to do each sublayer I am having issues with.

Intermittent Javascript MRAP error

$
0
0

I have a for loop which moves all elements of an "Artwork" layer to a "working" layer so that I can edit the elemets without a chance of affecting the original layer:

 

for (var i=app.documents[0].layers['Artwork'].pageItems.length-1; i>=0; i--)

{

          try

          {

                    app.documents[0].layers['Artwork'].pageItems[r].duplicate(app.documents[0].layers['workin g'], ElementPlacement.PLACEATEND);

          }

          catch(e)

          {

                    alert(e);

          }

}

 

This seems to work fine for three or four documents, and then begins to return the following error:

 

Error: an Illustrator error occurred: 1346458189 ('MRAP')

 

Action on every document then returns this error, even ones on which it has previously worked. The only solution is to quit Illustrator and relaunch.

 

Am I missing something obvious?

 

Thanks in advance.

Why can't turn off hyphenation by Script?

$
0
0

If hyphenation =false , set hyphenation =true , it is ok.

But hyphenation =true, can't set hyphenation = false.

My code: oTF.textRange.paragraphAttributes.hyphenation = false;

Why can't turn off hyphenation  by Script?


Script to round fractional CMYK colours?

$
0
0

This script must exist but I'll be damned if I can find it!!!

 

I work in a large printing company and we get artwork from all over that has dodgy CMYK colours (quick convertions from RGB obviously). We have noticed that these colours don't rip as well as rounded CMYK colours, so we spend a lot of time cleaning them up and rounding them down...

 

I'd like to be able to just run a script that does this to a whole document, including the colours inside gradients. So if for example the number is .5 or below we round down, or above we round up.

 

Does this exist, does anyone know?

 

CHEERS!

S

Input Text Information Via Script

Getting 1346458189 ('PARM') error

$
0
0

From the readme:

"An Illustrator error occurred: 1346458189 ('PARM')" alert (1459349)    Affects: JavaScript    Problem:     This alert may be popped when badly written scripts are repeatedly      run in Illustrator from the ExtendScript Toolkit      Scripters need to be very careful about variable initialization and      namespace conflict when repeatedly pushing a batch of Illustrator scripts     for execution in Illustrator via the ExtendScript Toolkit (ESTK) in a      single Illustrator session. Each script run is executed within the same      persistent ExtendScript engine within Illustrator. The ESTK debugger      uses BridgeTalk to communicate with Illustrator. One global, persistent      ExtendScript engine inside Illustrator handles all BridgeTalk      communications. The net effect is that the state of the ExtendScript      engine is cumulative across all scripts that ran previously.      The following issues with script code can cause this problem:        - Reading uninitialized variables.        - Global namespace conflicts, like when two globals from different         scripts clobber each other.    Workaround:     Initialize variables before using them, and consider the scope of      your variables carefully. For example, isolate your variables by      wrapping them within systematically named functions. Instead of:             var myDoc = app.documents.add();       // Add code to process myDoc           Wrap myDoc in a function that follows a systematic naming scheme:             function myFeatureNameProcessDoc() {      var myDoc = app.documents.add();      // Add code to process myDoc      }      myFeatureNameProcessDoc();

 

 

This makes zero sense to me. If javascript variables are being reused or 'clobbered' or your javascript is 'poorly written' (this is not defined) it should have no effect on the scripting engine. Errors should cause exceptions to be thrown, which can be caught by the script.  I'm getting these errors when I try to evaluate properties of valid objects, for instance trying to access pathItem.fillColor. It's happening in various (almost random) lines in my script. Javascript doesn't have namespaces so I don't know what a 'namespace confilct' would be. Accessing variables from nested functions also seems to be a problem.

 

Edit - this seems to be related to accessing global variables or variables defined in containing functions. For now, adding var to the first use in subfunction seems to have fixed the problem. What is strange is you don't get an undefined variable error, it just crashes when it tries to access the properties.

 

Edit - still not fixed. I'm guessing it has something to do with memory allocation, because I am processing a lot of big raster images in todays batch of files.

 

Edit - processed 84 files today with no errors the pattern I'm using is to use a bach file that loops

 

"(Path)/Extend Script Toolkit.exe" -run script

sleep 10

 

The script opens a group of files (in my case JSON files), processes one file, exports an ai file, deletes the JSON file, then exits.

Script for Selecting Open Paths in Illustrator CS6

$
0
0

I have created this script for selecting open paths in illustrator cs6 as the graffix plugin is not working under CS6.

 

Just save the following text in /Applications/Adobe Illustrator CS6/Presets/en_US/Scripts/Select Open Paths.js

 

 

if (documents.length > 0 && activeDocument.pathItems.length > 0){
 
          var allPaths = activeDocument.pathItems;
          var allPathsCount = allPaths.length;
          var openPathsAreLocked = false;
          var lockedOpenPaths = 0;
          var locked = false;
          for (var i=0; i < allPathsCount; i++){
                    allPaths[ i ].selected = false;
 
                    if( ! allPaths[ i ].closed){
 
                              try{
                                        allPaths[ i ].selected = true;
                              } catch (e) {
                                        openPathsAreLocked = true;
                                        lockedOpenPaths++;
                              }
 
                    }
          }
          if (openPathsAreLocked) alert (lockedOpenPaths + " open paths are locked or hidden (or their layer is locked or hidden) and cannot be selected");
}

TextRange.horizontalScale cannot be set to 100%?

$
0
0

I'm on 19.2.1 and if I have a TextFrameItem selected, app.activeDocument.selection[0].textRange.horizontalScale = 100 returns 100, but does not actually get applied to the TextFrameItem. Many other values work, just not 100. The closest I can get is 100.01.

 

Am I missing something?

Viewing all 12845 articles
Browse latest View live


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