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

illustrator script to rename artboard to specific name

$
0
0

I'm looking for a script that would allow me to rename illustrator artboard to specific name. Those would always be the same 3 names  in the same order (CV, UC and GE).

 

When I create my Illustrator doc I always have 3 artboards, those tree artboard need to be rename to:

 

artboard 1 to CV

artboard 2 to UC

artboard 3 to GE

 

I recently discovered the power of illustrator script. I really need the learn how to make my own..

 

Thanks in advance

 

Yolaine


Export file as a DXF

$
0
0

My script is working nice until I try to export my document. I am trying to export my document as a DXF file.  Using the Illustrator CS6 Scripting Reference I am using the TIFF export as a reference as there are no examples for exporting as a DXF (my luck!).  This is what I have in VBscript.  With this script I get the following error on the second to last line:

 

"Illegal argument - argument 2 - Enumerated value expected"

 

As you can see I do have one: "0" so I suspect the error lies elsewhere in the code?  I'll take a JavaScript example if you are not into VBscript since the two look very similar and I think I can adapt it.

 

Set App = CreateObject("Illustrator.Application")

Set FSO = CreateObject("Scripting.FileSystemObject")

 

Dim dest

dest = "S:\SOCAL\Section_32\Veg DXFs LC\SOCAL_CK67_pineLC"

 

Set DXFexport = CreateObject("Illustrator.ExportOptionsAutoCAD")

    If App.Documents.Count > 0 Then

        Set docRef = App.ActiveDocument

        Call docRef.Export (dest, 0, DXFexport)      ' 0 = aiDXF

    End If

Getting Page Count for a Multi-Page PDF file using Illustrator script?

$
0
0

Does anyone know how to get the page count of a multi page PDF file?  I know you can then open each page using the PDFFileOptions (pagetoopen).  But I need to know up front how many pages there are to loop thru to open each page and process each page.

 

Any Ideas?

select a word/text in illustrator

$
0
0

Hi,

 

how to select a text/word from textframe using script..

 

for ex,  "Adobe illustrator used for create logos, icons ,drawings"

 

in above sentence i want to select "illustrator"..

 

pls help

 

Thank you

"Isolation Mode" and Javascript.

$
0
0

Hi All,

 

Does anyone know of a way to get out of IsolationMode using Javascript?

 

I am trying to create a Duplicate of a Selection on a Tempory Layer.

The selection is often quickest to get to by Isolating.

Then running script.

 

I'm getting this error:

 

Error 9034: Cannot add a new layer as sibling to 'Isolation Mode' synthetic layer.

->  tempLayer = app.activeDocument.layers.add();

 

I also have this issue with another Script I use to Save Artwork.

If Isolation Mode is active when script is run, file is saved with non-isolated sections "Dimmed"

Would be nice to "Idiot Proof" the code a little more by getting out of Isolation mode if need be before saving.

 

Snippet of save code below:

saveName = new File(FilePathAndName);
saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT5; 
saveOpts.generateThumbnails = true; 
saveOpts.preserveEditability = true;
app.activeDocument.saveAs( saveName, saveOpts );

 

Fingers Crossed there is a way to access "Isolation Mode" using Javascript.

Both scripts are too much for an action.

I can't run action from Javascript... can I? (boo)

and I realy don't want to go down the path of running JS from an Action, then calling VB to call a different action bla bla.

 

am using CS6 with CC coming soon...

 

Thanks in advance...

Set unit preferences (Javascript)

$
0
0

I can't find a way to set the unit preferences for Illustrator CS6/CC using JavaScript.

 

I found that this works (setting units for stroke):

var units = 2; // 0-inches, 1-milllimeters, 2-points

app.preferences.setIntegerPreference("strokeUnits", units)

 

But I want to set the ruler units ("General" in the interface), and this does not work:

app.preferences.setIntegerPreference("rulerUnits", units)

 

Any help?

Peter

Scripting Variable Fonts in Illustrator

$
0
0

Hy there,

 

How can I set the parameters for a variable font?

The TextFont.axisVector is 'Read Only'

 

Greetings, Akiem

JETalmage's Script Library

$
0
0

Hi -- just wondering if anyone knows what became of the great repository of AI scripts JET had posted on the web -- I have been using a modified version of his Label Script and went looking recently for his other ones, but all the links point to a site that is now under construction. Are they archived elsewhere? or is JET coming out with a commercial package (I'll be first in line to buy!)?

 

Thanks!

 

-g-


Change spot color and move to specific layer

$
0
0

I am new with scripting in Illustrator but see a need to script some repetitive tasks.

I start with a document that has most art on Layer 15 colored with various spot colors

I need to select all strokes of a specific color, change it to another color and move it to a different sub layer.

 

Layer 15

     all art

Template layer

     Cut

     Bleed

     Score

 

Can someone please get me started with the commands? I picked up on others who were moving items to different layers, but not changing colors also.

How to reffer for center point while positioning

$
0
0

How to reffer for center point of an object while positioning?

вапрв.png

i.e. I need to position an object relating for it center point.

Problem loading an artboard to extension with multiple images

$
0
0

Hello guys,

i have a situation while laoding an artboard. This artboard consists of 4 images. while trying to load it into illustrator its working fine and while loading on to an extension only the first image is opening fine and all the remaining were breaking.

I have tried loading different artboards with multiple images. They worked fine.

That file which i am unable to load into extension was given by our client. I dont know whether there is a problem in that .ai file or what ever. This is the only file i am unable to load to extension.

Could come one please help me with this

End of story

$
0
0

Hello all. I have a finnicky problem whereby I've created a script to clean up some text and the result is that in some instances I end up with a blank space preceding the end of story. I wish to find this blank space and delete it. The problem is in identifying the end of story, which you all know is the hashtag symbol. But of course you can't search a hashtag. I've tried \$, but that doesn't work because there are multiple elements selected and it only does the last one. I've tried \n, but that doesn't work. I've tried \r but that doesn't seem to work either.

 

Any thoughts?

 

Marcrest

Calling functions from UI palette

$
0
0

Hello,

From what I understand, you can't call complex functions from a scripted UI palette, only from "dialog" windows (which are usless in my case) because I need the persistance of a palette.

 

I have a series of scripts in use now that are  accessed from the usual "file-scripts folder" within Illustrator itself (about 27 of them).  I want to script a palette window so users can acces them without the usual mouse clicks down the menu system.

 

I'm able to call a simple "Hello World" type function using the "onClick()" method from a button of a scripted palette window, but I cannot use my regular working scripts inside a function that's called from the button.  In X-Code, I was able to write my scripts individually, then just add them to a main floating window via a separate function when they were completed.  But, I'm finding Javascript a little more tricky.

 

If I copy my other's script code into the function in the palette window script, it runs, but it runs before I click the button! --  After in runs, then the palette window is displayed(?).  If I try to use the execute() method with "onClick", the script just opens in the SDK, it will not and does run in Illustrator.

 

I take both of these as clear indications that I have no clue what I'm doing (or that I'm trying to do the impossible).

 

I did find someone with a similar problem, but they were scripting After Effects and were offered this solution:

 

system.callSystem ('afterfx -r "/C/Program Files/Adobe/Adobe After Effects CS3/Support Files/Scripts/GlobalVars.jsx"');

 

 

Is there anything I can do in Illustrator that will allow me to call (or execute) my other scripts/functions and have them execute within Illustrator?

 

Thanks for any and all help!

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.

Creating a dynamic action to use with app.doScript() method.

$
0
0

Since building dynamic actions is a topic unto itself, we often search for a reference thread to show somebody how to do this - and we often do so while trying to discuss work which is already involved and has nothing to do with actions or loading and playing them. Therefore I'm creating this thread to show an example and I'll paste the url to it when such questions arise.

 

Sometimes in Illustrator scripting we need to accomplish tasks which (sometimes counterintuitively) do not have scripting access via the DOM.

Fortunately since Illustrator CS6, they gave us the ability to play an action from a script with the app.doScript() command - which is not at all the same as Indesign's function of the same name. This one lets you play an action that exists inside the Actions panel. Immediately this may seem disappointing as users cannot be counted on to have specific actions at any given time.

However, they also gave the ability to load and remove actions from .aia action files. Your .aia file just needs to be somewhere and app.loadAction() can read it right into the Actions panel. Same with app.unloadAction(setName, actionName) - where (thanks to qwertyfly) using (setName, "") an empty string argument for the action name will remove the entire set. And when you try to remove an action that does not exist, well, it throws an error - which is how you can check for making absolutely sure that an action set is completely removed.

This may seem like a lot of work - to write a file, read it, play it and then discard it, often to do something that you'd think scripting should do in the first place.

 

Sometimes the action alone is enough to satisfy an objective - such as changing the document color mode. Other times it is necessary to alter actions in order to get use out of them - such as when you try to create a routine for saving a high-resolution "Export" JPG that is different in output and options form the "Save for Web" JPG. You may want to change some of the parameters such as resolution or the actual destination of the file.

Here is how you can do this.

 

First, record your action as you would normally: record a new set with a new action, call them what you need and then in the Actions flyout menu, save out a .aia file where you can find it. You can open the file in a text editor and read the contents - they are lines of special Actions 'code' which contains some cryptic text.

There are lines which look like a bunch of gibberish characters, they are hex-encoded strings for some parameter item which are strings, and they contain above them a number to signify the amount of characters inside the encoded string. (this is important later because this number also needs to be set properly when you put your own value in there) Other parameter items are simple numbers, but their keys are still obscured.

The truth is, while the string parameters are hexadecimal-encoded, the keys are both hexadecimal and decimal encoded! So if you wanted to know the special 4-letter keys, you'll have to run those through two decoder routines.

 

Next, you will need to put this entire string into your script and use some string-replacement or string-building to put your own data in those places of the action string where they matter. For example, putting your own file path into a save action.

 

And, after that you need to write a procedure for writing this new altered string to the file system and loading it into your Actions panel. Mind you, to leave things "as they were" you would need to remove the .aia file and the action that you have loaded.

 

Let's try with the save-a-jpeg workaround!

Here is the .aia string which is recorded from an Export JPEG action.

 

Screen Shot 2017-02-10 at 3.04.33 PM.png

/version 3

/name [ 8

  5475746f7269616c

]

/isOpen 1

/actionCount 1

/action-1 {

  /name [ 11

  4578706f7274204a504547

  ]

  /keyIndex 0

  /colorIndex 0

  /isOpen 1

  /eventCount 1

  /event-1 {

  /useRulersIn1stQuadrant 0

  /internalName (adobe_exportDocument)

  /localizedName [ 9

  4578706f7274204173

  ]

  /isOpen 1

  /isOn 1

  /hasDialog 1

  /showDialog 0

  /parameterCount 7

  /parameter-1 {

  /key 1885434477

  /showInPalette 0

  /type (raw)

  /value < 100

  0a00000001000000030000000200000000002c01020000000000000001000000

  69006d006100670065006d006100700000006f00630000000000000000000000

  0000000000000000000000000000000000000000000000000000000000000000

  00000100

  >

  /size 100

  }

  /parameter-2 {

  /key 1851878757

  /showInPalette 4294967295

  /type (ustring)

  /value [ 25

  2f55736572732f566173696c7948616c6c2f4465736b746f70

  ]

  }

  /parameter-3 {

  /key 1718775156

  /showInPalette 4294967295

  /type (ustring)

  /value [ 16

  4a5045472066696c6520666f726d6174

  ]

  }

  /parameter-4 {

  /key 1702392942

  /showInPalette 4294967295

  /type (ustring)

  /value [ 12

  6a70672c6a70652c6a706567

  ]

  }

  /parameter-5 {

  /key 1936548194

  /showInPalette 4294967295

  /type (boolean)

  /value 1

  }

  /parameter-6 {

  /key 1935764588

  /showInPalette 4294967295

  /type (boolean)

  /value 1

  }

  /parameter-7 {

  /key 1936875886

  /showInPalette 4294967295

  /type (ustring)

  /value [ 1

  32

  ]

  }

  }

}

 

We can see many parameters and their various cryptic blocks, but what you want to do is decode as many /type (ustring) elements as possible to get a sense of what the action is doing. At this website, you can do this fairly easily although tediously: Convert Hexadecimal To String Online

For example: "4a5045472066696c6520666f726d6174" turns into "JPEG file format".

In this action example, I am not worried about changing the other parameters dynamically - I'm assuming the settings used in my action are suitable for my purposes such as resolution being 300 for all time. The part I'd like to change is my file path so that my JPEG goes to the right place.

/value [ 25
2f55736572732f566173696c7948616c6c2f4465736b746f70
]

This line yields: "/Users/VasilyHall/Desktop"

So this is the line I'll need to replace.

 

Before anything else - here is how I'd embed the action string with ease. Using a text editor like Sublime text which lets you put many cursors down at one time, I can paste the action string in and find every nextline character. Then it's easy to highlight each line and put quotes around it as well as a comma in the end, or plusses - depending if you want to store the string as an array or a plain string in the script.

Screen Shot 2017-02-10 at 3.16.48 PM.png

I find the plusses a little cluttering so I opt to use this format:
var actionString = [     "string",

     "string"

].join("\n");

 

So my dynamic portion of the string which will be used with string replacement would look like this:

 

"  /value [ {{number_of_characters}}",

"  {{hex_encoded_path}}",

"  ]",

 

When the action is ready to be dispatched, a string replacement would look like this:

var myNewPath = Folder.myDocuments.toString() + "/Destination";

var myNewPathEncoded = hexEncode(myNewPath); // find a hex encode function via google
var thisActionString = actionString.replace("{{hex_encoded_path}}", myNewPathEncoded).replace("{{number_of_characters}}", myNewPath.length);

 

Now it's time to write the file.

var f = File(actionFileLocation);

f.open('w');

f.write(thisActionString);

f.close();

 

And now it's time to load the action.

app.loadAction(actionFileLocation);

 

Now we can play the action.

app.doScript("Export JPEG", "Tutorial");

 

This should save your jpeg, and as of this writing, this is the only way to get the JPEG export which isn't the Save-for-Web variety.

But, let us not forget the cleanup.

 

Remove the .aia file:

f.remove();

 

Remove the single-use dynamic action:

app.unloadAction("Tutorial", "");

 

There you have it: building dynamic actions to do simple and non-simple things, which regular scripting just can't do.


Is there a way to batch rename artboards in Illustrator CC?

$
0
0

Is there a way to batch rename artboards in Illustrator CC?

I have 20 different artbords that i want to rename with a specific name and number!

/Pål

jsx script illustrator - replace items color with a corresponding swatch pattern

$
0
0

I am attempting to create a script to replace all the colors in a picture with a number pattern. I have created a script but it does not work as intended.

The picture is coloured with swatches and need to be replaced by a swatch with the same name but for a "." at the end, i.e. all items of colour Bh will need to be replaced with Bh. pattern.

 

 

doc = activeDocument,

swatches = doc.swatches,

items = doc.pathItems;

var correspondingSwatch;

 

for (var c = 0; c < swatches.length; c++) {

    correspondingSwatch = null

 

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

        if (swatches[i].name == swatches[c].name + "." ) correspondingSwatch = swatches[i];

    }

 

    if (correspondingSwatch != null) {

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

            if (items[i].fillColor == swatches[c].color) items[i].fillColor= correspondingSwatch.color;

        }

    }

}

 

 

The first and second for loop work as intended but the third for loop does not.

(items[i].fillColor == swatches[c].color) i want this to return true when the color of the item[i] is the same as the swatches[c] but it does not.

(items[i].fillColor  = correspondingSwatch.color) i want this to fill in the item with the correspondingSwatch pattern, not the color. However I do not know the syntax to use a swatches color to paint an item.

 

Thank you any one who gives this a read, i am familiar with programming but am just starting on adobe illustrator scripting.

If you could change the code and send it back that would be great, or even telling me what methods or variables to use.

Optimize objects stacking order for vinyl cutting

$
0
0

Hello,

i am looking for a script for optimizing vinyl cutting speed.

The script should be similar to following , but needs to sort the selected objects by the relative position to page origin and not the height from page origin as it does now

script from Arranging stacking order from top to bottom

//David Entwistle

 

var thisDoc = activeDocument;

 

// get selected objects

var selObj = thisDoc.selection;

 

// count the selected objects

var selObjCount = selObj.length;

 

// sort selected objects by their height from the page origin

var byProperty = function(prop) {

    return function(a,b) {

        if (typeof a[prop] == "number") {

            return (a[prop] - b[prop]);

        } else {

            return ((a[prop] < b[prop]) ? -1 : ((a[prop] > b[prop]) ? 1 : 0));

        }

    };

};

 

var symbolsSorted = selObj.sort(byProperty("top"));

 

// for each object in turn in the ordered selection, BringToFront

for(i = selObjCount; i >0; i--){

          var currObj = symbolsSorted[i-1];

          currObj.zOrder(ZOrderMethod.BRINGTOFRONT);

}

 

redraw();

alert("Selected Objects Sorted = " + selObjCount);

 

 

Any help is welcome

Panagiotis

Make compound path in Adobe Illustrator by script

$
0
0

There are some compoundPathItems in myfile.ai

How can i run "Object > Compound Path > Make" or send "ctrl+8" from jsx? At line with comment ERROR HERE i get error message "A new object cannot be created at the specified location".

 

 

#target illustrator

if (app.documents.length > 0) {  var idoc = app.activeDocument;   var cp = idoc.compoundPathItems.add();  var allPaths = activeDocument.pathItems;  //Select objects  for(var i = 0;i < allPaths.length;i++){  allPaths[i].selected = true;  }  var selection = app.activeDocument.selection;  for (var i=0; i<selection.length; i++) {  selection[i].move (cp, ElementPlacement.PLACEATEND); // move selected path inside the compound path ERROR HERE   selection[i].evenodd = true; // necessary to determine "insideness" or to make holes.    }  alert(selection);

creating outlines from text using javascript in Illustrator CS5

$
0
0

Hi everyone,

 

Is there a way to select all of the text on all artboards and CREATE OUTLINES using Javascript? I've googled and googled, but I can't seem to find any help. The text that Adobe provides for scripting has this option for saving to FXGs which is preserveTextPolicy or something similar, but I need the same type of solution for saving as an AI file or as a command before the save. I'm currently working in windows, but am writing this script for use on a MAC. If there isn't an internal way of doing this through Javascript, does anyone know of another?  I would imagine it would be possible through Applescript since it can access the application's GUI, but I'm not sure. A javascript solution would be preferable, but any solution would work at this point.

 

thanks,

Matt

Viewing all 12845 articles
Browse latest View live


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