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

relink script issue.

$
0
0

Hello, everyone.

 

I am writing the script for relinking on illustrator file. It is perfectly working on illustrator CC2014. but I got the issue on illustrator CC2017 and illustrator CC2018.

 

Note: I am mentioned manual link location and Script linked locations differ on link palate location. snapshot for your reference.

 

kindly advice how to mention the folder location in the script.

 

Issue reference:

 

Screen Shot 2018-11-26 at 9.31.00 PM.png

 

Folder structure reference:

 

Screen Shot 2018-11-26 at 9.41.54 PM.png

 

Script reference:

 

#target illustrator-21 

 

function linkReplacer() { 

     var orginalUIL = app.userInteractionLevel; 

     app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; 

 

 

     if (app.documents.length == 0) { 

          alert('Please have an "Illustrator" document open before running this script.'); 

          return; 

     } else { 

          docRef = app.activeDocument; 

     } 

        

 

 

     var defaultFolder = new Folder (Folder(app.activeDocument.path + '/../040 Images/043 High Res')); 

     var psdFolder = defaultFolder; 

     if (psdFolder == null) return; 

      

     with (docRef) { 

          var placedFiles = new Array(); 

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

               placedFiles.push(placedItems[i].file.name); 

          } 

           

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

               var rePlace = new File(psdFolder.fsName + '/' + placedFiles[j]); 

               if (rePlace.exists) { 

                    placedItems[j].file = rePlace; 

               } else { 

                    alert('File "' + placedFiles[j] + '" is missing?'); 

               } 

          } 

     } 

     app.userInteractionLevel = orginalUIL; 

 

linkReplacer();


Save as .ait (adobe illustrator template)

$
0
0

Hi everybody,

 

I would like to save my file as a .ait format. I have tried browsing the forum but it seems impossible to save a file as a .ait file. I also already have tried to rename the file as "xxx.ait" when saving it but it does not work.

 

Thank you for your answers,

 

Happy holidays !!

 

Miyano

Help......Change Document Size

$
0
0
How to change (Illustrator)Document Size. As Old Document Size Width:400
Height:600 I would like to change Width:450 Height:650
Similar features Menu-->File-->Document setup....

Convert string (string of JSON) to JSON object?

$
0
0

**EDIT**

I finally figured out how to use #include instead of file.read();. This solves my immediate problem. However I am still curious as to whether it's possible to do what I'm asking for below, just in case there comes a situation where for whatever reason I cannot simply use #include. Thanks everyone. =)

**EDIT**

 

**EDIT 2**

Anyone know how to use #include for a file whose name is determined during script execution?

For example.. the variable orderNumber is generated by a prompt window (lets say the result is 1234567). the file i want to include will be named "1234567.js).

What I want to do is something like:

#include "~/Desktop/Info Folder/" + orderNumber + ".js"

(then I want to assign a variable to the result somehow, since it's simply an anonymous object at this point and i don't know how to access it's contents);

**EDIT 2**

 

Hey all. I have a (most likely really stupid) question about how to take a string that contains the JSON text and simply change it's type from "string" to "object"... I'm probably wording this very badly.

 

I'm fetching a .js file from my local network and setting a variable to the result of file.read();

 

The contents of the file is an anonymous object in JSON. However, when i use file.read(); the object is brought in as a string, like this:

 

'{"roster":[{"name":"Fink","number":"19","jerseySize":"XL","qty":"1","topId":"78531"},{thi s is the next player},{this is the next player}]}'

 

That is a massively simplified version of what i'm actually reading, but you get the point. I want to be able to bring that object into the script that I'm running and create new objects based on the pertinent information (in this case i only need the values for "name", "number", and "jerseySize").

 

So my question is this. how do i turn the above string of JSON into:

 

var roster = [

     {

     "name":"Fink",

     "number":"19",

     "jerseySize":"XL"},

     {

     next player

     },

     {

     next player

     }

]

 

???? A google search reveals the method JSON.parse(text). But that is not supported in ESTK.

Finding open paths in Illustrator CC 2017

$
0
0

Does anyone know of a script to find open paths in Illustrator CC 2017? I finally sucked it it up and 'upgraded' to CC and now my old script won't work. Any help or suggestions is greatly appreciated.

Replacing text contents via script

$
0
0

Hi everyone,

 

I want to replace the word "PANTONE " with "P." in all text objects in the document.

i've managed to take content from one textFrame and replace it just like i want, but it works only in JS console

 

 

function test(){

var doc =app.activeDocument;

   var t = doc.textFrames.getByName("usedcolor5").contents.replace("PANTONE ", "P.");

    return t;

};

test();

 

 

my file looks something like this:

 

 

Script - Create a small circle at the corner of the artboard

$
0
0

Can someone help me or guide me to the right direction of how to do this?

 

Basically, this is what I want the script to do

 

1. Make artboard the size of my selected artwork + 1" offset

2. Create a circle at each of the corner of the artboard

 

I figured out the script for #1 but I can't find figure out #2. Could anyone help?

 

Thanks in advance

Unable to select same Graphic style on pasted eps

$
0
0

I open an eps.

Copy the whole graphic.

Open correct template and paste copied graphic.

The template has Graphic styles with same fill and stroke (no other attributes exist) as in pasted graphic.

However, I cannot select elements in pasted graphic based on Graphic Style even though pasted graphic contains elements with same stroke and fill.

I cannot select on same stroke and fill either.

 

I checked Document Colour Mode and made sure it was RGB Color.

However, when I select the element and double click Color Picker the initial window is showing New Color 1100 so I suspect even though the same style illustrator is assigning the element color and stroke as new.

 

This selection process is a step in an action for applying styles and has worked - then it doesn't.

 

Probably something simple is changing parameters but appreciate suggestions as to where the issue might lie.

 

This is old CS2 on Mac PPC G5 but still pays for itself doing simple processing of output files.

 

Any advice appreciated as many hours trying to figure this out.

 

Thank you

 

Michael


Batch relinking broken filelinks in .ai files

$
0
0

     Hi, am wondering if it's possible to relink files in batch , my gut is saying no as all scripts ive found for relinking files references internal functions such as "app.documents". Aim is to update lots of broken links in a company fileshare (some files are 300+ links). Are there any other options?

 

Files are hosted on a windows server, but published as an apple fileshare using some software. This works fine, but I had to rename a folder and its broken lots of filelinks as a result.

 

I want to essentially find and replace a broken link path for all .ai files in the directory and all subdirectories with the new amended path.

 

The loop in red is giving me an "undefined is not an object" error. I'm guessing app.documents.length is undefined.  I presume this should be where an input box appears when run from the scripts menu in the application. What am I missing?

 

Is there a way to relink files via script outside of illustrator? if there are xml files I can find and replace manually, this would be easier for me!

 

Any suggestions welcome!

 

The script is below:

 

var i, j, searchfolder;   

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

    doc = app.documents[j];   

   

    imgs = doc.links;   

    path = "afp://COMPANY-FP01 IP._afpovertcp._tcp.local/IllustratorScriptTest/";  //

    searchfolder = new Folder(path);   

 

   for (i=0; i<imgs.length; i++)   

    {   

        // Missing?   

    $.writeln("Image "+i);   

        if (imgs[i].status == LinkStatus.LINK_MISSING)   

        {   

        $.writeln("Missing: "+imgs[i].name+" lookign in "+searchfolder);   

            // Do we have a file?   

            imglist = findAnyFileDownThere(imgs[i].name, searchfolder);   

        $.writeln("Found "+imglist.length+" possible replacements.");   

            if (imglist.length == 1)   

            {   

                // Oh yeah   

                imgs[i].relink(imglist[0]);   

        $.writeln("Relinked to "+imglist[0]);   

            }   

        }   

    }   

}   

function findAnyFileDownThere (filename, path)   

{   

var result, folderList, fl;   

result = Folder(path).getFiles (filename+".*");   

if (result.length > 0)   

  return result;   

folderList = Folder(path).getFiles(function(item) { return item instanceof Folder && !item.hidden; });   

   

for (fl=0; fl<folderList.length; fl++)   

{   

        $.writeln("Looking in: "+path+"/"+folderList[fl].name);   

  result = findAnyFileDownThere (filename, path+"/"+folderList[fl].name);   

  if (result.length > 0)   

   return result;   

}   

return [];   

}   

Selecting a Single Anchor Point at the Start of a Script

$
0
0

Sorry to ask but is there a way to automatically select an Anchor Point?  It will always be the Lowest point (and because there will be multiple on that Y-axis) I want the Left most point.

 

Capture3.PNG

 

 

Thank you!

Delete unnecessary points

$
0
0

Please see this post in the main forum. I am looking for a script (if one exists) that will delete unnecessary/redundant points.

 

My OP:

 

Let's say I have a rectangle, and in addition to the corner points, there are extra points along the paths. I want to get rid of these, as they have no purpose. Object> Path> Simplify doesn't do it, nor does Object> Path> Cleanup. I can use Remove Anchor points, but I have to select them all first.

 

Thanks.

Is there any possibility to check all the images are placed in 100%?

$
0
0

Hello Guys,

 

Hope someone can helpme regading my issue.

 

Is there any possibility to check all the images are placed in 100% or not.

 

for example if you see the following screenshot, there you can find the links that what ever we have used in artwork. But few of links were not in 100%. So I request you guys a script to work with following requirements.

 

  • Once we run the script, it must shoiw the number of images are not 100%. For example if you see the screenshot there you can see 9 images. Out of 9 images, 6 images are not 100%.
  • So the script must show that 6 image are not 100%.
  • 99-101% can be ignore. Sometimes images were placed 99 to 101%. This tiny difference can be ignore in the script.

 

Picture 4.png

 

Hope this is clear. If you need any extra information, please let me know.

 

I appriciate your reply.

 

Thanks & regards

FroQ

script to align selected objects to artboard

$
0
0

Hello, I was wondering if anyone had a simple solution to aligning selected items to the artboard. I was going to create an action but then realized it would be more convenient for me to include it in my script file....I have a script to align objects with each other but they dont align to the artboard. Any suggestions?

OpenOptions not working

$
0
0

I am trying to open some dxf files through a script I wrote and the first dialog box that pops up is the scale select box.  I tried setting the option in my script but is keeps having an error when it get to the scale I set.

 

 

 

Private appillustrator As New Illustrator.Application

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        'Select the URD drawings folder you want to run the program on.

        Dim result As DialogResult

        MsgBox("Please select the folder containing the drawings you want to convert to the .dxf format.")

        result = FolderBrowserDialog1.ShowDialog

        Dim ext As String

        ext = ".ai"

'Check for files with the 'URD' extension.

        For Each file As String In System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath)

            'System.IO.Directory.CreateDirectory()

            Dim slashposition As Integer = file.LastIndexOf("\")

            Dim filenameOnly As String = file.Substring(slashposition + 1)

 

            If IO.Path.GetExtension(file).ToLower = ".dxf" Then

                Try

                    'appillustrator.Visible = True

                Catch

                    appillustrator = New Illustrator.Application

                End Try

 

 

appillustrator.Open(file, False, Illustrator.AiAutoCADGlobalScaleOption.aiFitArtboard)

 

appillustrator.ActiveDocument.SaveAs(file & ext)

Else

                'Skip this drawing as its not a 'DXF' and go to the next drawing.

            End If

 

 

        Next

 

        'Exit Illustrator.

        appillustrator.Quit()

        MsgBox("Your drawings in" & FolderBrowserDialog1.SelectedPath & " have been completed." & vbCrLf & vbCrLf & _

               "Please review the converted files for errors")

 

 

 

    End Sub

placedItem file (re)placement failure in Javascript

$
0
0

Greetings,

 

While scripting some automated placedItem replacements, I stumbled upon some issues with the feature failing in specific cases.

While most of them ended up working somehow at a later date, this one still fails:

 

Namely, the placing of an SVG image using a script. More specifically, I replace an existing graphic with one from an SVG image.

It doesn't matter whether I try to place it or replace an existing image, Adobe pops up with the following helpful error message:

'The file "TEST.svg" is in a format which cannot be placed'

 

Naturally, the test-image has been created using illustrator itself, and manually placing OR replacing the file through the interface 'just' works.

 

Should I be dropping this in a bug-report forum or is here ok?

Or are there specific demands for placeable SVGs?


How Photoshop style duplicate current page make illustrator script.

$
0
0

How photoshop style duplicate current page make illustrator script.

In fact, such a feature would be very nice in the illustrator too.

How to test if two PathPoints are the same

$
0
0

I am trying to write a function that takes a PathPoint and returns its index relative to it's parent PathItem. Something like this:

 

function getPathPointIndex(pathPoint) {     var pathPoints = pathPoint.parent.pathPoints,          i,          length = pathPoints.length;     for (i = 0; i < length; i++) {          if (pathPoint === pathPoints[i]) {               return i;          }     }     return false;
}

 

However I have found when working with PathPoint objects even if they represent the same point they rarely identify as the same object. This can be demonstrated with the following example. Create a new Illustrator document and draw a path with at least two points then run the following:

 

var pointA = app.activeDocument.pathItems[0].pathPoints[1],     pointB,     i,     length = pointA.parent.pathPoints.length;

for (i = 0; i < length; i++) {     var pointB = pointA.parent.pathPoints[i];     if (pointA === pointB) {          $.writeln('index ' + i + ': Same');     } else {          $.writeln('index ' + i + ': Different');     }
}

 

On my system the pointA and pointB are never the same. It doesn't make much that a point doesn't exist in it's parent element.

 

You will notice that I used the second PathPoint (index 1) to demonstrate this issue. This is because the script works as expected if the first PathPoint (index 0) is used.

 

It would be great if somebody could please:

1. Explain this phenomenon

2. Provide a solution to testing if two PathPoints are the same

3. Get the index of a PathPoint relative to its parent PathItem (this should be easy if point to can be achieved)

 

Thanks

Creating a layer depending on the selection from the list

$
0
0

Hi,

 

I have a pretty silly question. As my knowledge of JS is vary small, I have a problem with dropdown list in my custom dialog.

I'm currently writing a script that is a part of an action that exports Normalized PDF via ESKO's add-on.

I want script to check if there is a Layer named: A114 or A17 or R114 or R17, if so let the action continue.

If there is no such layer, a window should appear, where I could choose a name for my layer from dropdown list (or radio button).

And then script creates layer with a chosen name, saves a file and let the action continue.

 

I couldn't find any way (or i just asked wrong questions): how to check which option from dropdown list is selected and depending on that choice how to make a layer with given name.

 

I've got something like this so far.

 

var doc = app.activeDocument

var docLayers = doc.layers

 

 

//Polymer choice window

 

 

var polymer = new Window ("dialog", "Choose material");

        polymer.orientation = "column";

        polymer.alignChildren = "top";

        var subG = polymer.add ("group");

            subG.orientation = "row";

            var inp = subG.add ("group");

                inp.alignChildren = "fill";

                inp.add ("statictext", undefined, "Choose the type and thickness of the polymer:");

                inp.orientation = "column";

                    var ddl = inp.add ("dropdownlist", undefined, ["Asahi 1,14","Asahi 1,7","-","Rave 1,14","Rave 1,7"]);

                    ddl.selection = null;

            var btn = subG.add ("group");

                btn.orientation = "column";

                btn.add ("button", undefined, "OK");

                btn.add ("button", undefined, "Cancel");

 

 

//define the function for checking if layer exists

 

 

function doesLayerExist(layers, name) {

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

        if (layers[i].name==name) return true;

    }

    return false;

}

 

 

//define the function for creating a layer depending on the selection from the dropdown list

 

 

function createPolymerLayer(){

  

    }

 

 

//if layers exists send them to back

 

 

if (doesLayerExist(docLayers, "A114")) {

 

 

    alert ("A 114", "OK", false);

    docLayers["A114"].zOrder(ZOrderMethod.SENDTOBACK);

    doc.save ();

 

 

} else if (doesLayerExist(docLayers, "A17")) {

   

    alert ("A 17", "OK", false);

    docLayers["A7"].zOrder(ZOrderMethod.SENDTOBACK);

    doc.save ();

 

 

} else if (doesLayerExist(docLayers, "R114")) {

   

    alert ("R 114", "OK", false); 

    docLayers["R114"].zOrder(ZOrderMethod.SENDTOBACK);

    doc.save ();

 

 

} else if (doesLayerExist(docLayers, "R17")) {

 

 

    alert ("R 17", "OK", false);

    docLayers["R17"].zOrder(ZOrderMethod.SENDTOBACK);

    doc.save ();

 

 

} else {

 

 

    alert ("Lack of an appropriate layer determining the type of polymer!", "Provide the type of polymer!", true);

    polymer.show ();

 

}

(Alerts in doesLayerExists function are just for me, so i could see what function actually did.)

 

Also sorry for my english

Where's Illustrator Scripting CC 2019 reference?

Batch export .ai to .png produces files without extension - please help

$
0
0

I created an Action to batch export a folder of .ai files to create 300dpi .png's of the .ai file's artboard. I did this by simply recording "Export...as png" with my desired settings then Batch running the Action on desired folder of .ai files.  The files were successfully exported, the trouble is that the exported files lack a .png file extension. My intent is to take these PNG files and

merge them into a single PDF using Acrobat Pro. Unfortunatly, without the .PNG extension, Acrobat Pro does not recognize the file types and does not let me use the Combine Files feature on them. Going back and manually adding a .png at the end of the exported files defeats the time-saving purpose of Batch Processing all together. Is there something I am missing or doing incorrectly? I have included screenshots of 1) My Batch Action settings 2) folders showing files without .png extension and 3) visual of what I see when I am trying to combine PNGs into a PDF. Assistance would be greatly appreciated!

Screen shot 2011-10-03 at 6.38.19 PM.png

Screen shot 2011-10-03 at 6.58.52 PM.png

Screen shot 2011-10-03 at 7.01.10 PM.png

 

- Erin

Viewing all 12845 articles
Browse latest View live


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