Illustrator Scripting :: Move PageItems From One Layer To Another?
Dec 19, 2012
I am working on a script to standardize layers and I need to move all the pageItems from a layer called "PART_NUMBER" to a layer named "STATIC".
following code at the arrow...
I am using "test" to troubleshoot the move.
standardizeLayerNames() // This function verifies that the Layer names conform to the standard Layer names.
function standardizeLayerNames() {
var myDoc7=app.activeDocument
var myLayerCount7 = myDoc7.layers.length
I have a script that measures the repeat interval and gap between print impressions printed using a print cylinder (for the production team to know which print cylinders to use, and what to expect once it prints, when looking at the proof sheet). Basically it just measures the distance from the beginning of one print impression to the beginning of the next (these are printed with a cylinder, so every time the cylinder rotates a new print impression happens) as well as the distance in between prints. That part works great.
In order to get these meaurements, Illustrator is measuring the distance from a zero point on the artboard to the left side of a marker I made called "repeat", and it is assigned a variable called rawRepeat. What I'd like to do is have the script take that rawRepeat value and use it to move a copy of the print impression to the right by exactly that variable amount and paste it beneath the marker called "repeat". I have been doing this part manually, but haven't been able to figure out how to get illustrator to do this for me.
Here's the script I am using:
var myDocument = app.activeDocument; var selectedObject = myDocument.selection; var activeLayer = app.activeDocument.activeLayer; var layerName = activeLayer.name; activeLayer.name = "plate";
I am trying to grab specific spot colors and move them to separate layers for our cutting software. In this case I am trying to grab "perimeter cut" and move it to a layer called "tc 1" I get the following error when I try to run the script.
#target Illustrator var idoc = app.activeDocument; var ipath = idoc.pathItems; if (ipath.typename == "SpotColor") { if (ipath.spot.name == "perimeter cut") { ipath.move(tc 1, ElementPlacement.PLACEATBEGINNING). } }
I'm trying to write a script that renames a layer, and group within the layer, then an object within the layer (but not a part of the group) and have it run in a loop.
Here's what I've got so far, the group rename doesn't work.
#target Illustrator var doc = app.activeDocument; idLayers(doc)//IRename layers idGroups(doc)//Rename groups function idLayers(doc){
[code]....
I haven't put in anthing to rename the single object yet since I cant even get the group rename to work. I suspect that the group re-name section isn't working because I'm either using bad syntax or an invalid command.
I'm trying to create a script via javascript for Illustrator.
My problem is : I have a AI file with multiple layers, i want to create one artboard per layer, in order to export a multipage PDF ( each page contain 1 layer ).
The layers represents the differents type of print ( vernish, color, hot gold, pressure ... ) and/or color type ( Pantone, CMYK, cut, kisscut ... ). My client want a PDF for see each type of print or color type per page.
I'm trying 2 ways :
1st solution : Create new artboards, and duplicate ( or move ) layers content on the new artboad, but the function move/duplicate don't work to move content on another artboard.
2nd solution : Create new document with the same number of layers as artboard and duplicate layer to the new artboard on the new document.
All I am trying to do is move an anchor from one location to another using vbscript. I have searched everywhere and scoured the scripting references but I have not been able to figure this out as of yet.
I am able to select anchor points without an issue....moving those points seems to be a problem.
I have a document with a single layer and a single group (GroupItem) in that layer.
Unfortunately, I didn't create the .ai file, so I don't know exactly what is in the group; however, there appears to be a bunch of complex clipping masks and gradient effects, etc. deeply nested within it.
I've successfully scripted a few tasks like resizing the group with no ill effect... in other words, this works as expected:
However, as soon as I try to move/translate/reposition the group, all the effects/masks seem to go wonky, I've tried all of the below with no success (200 is just arbitrary as a test):
I have no problem moving the group around on the document with my mouse... all the effects/masks are still nice and clean, so I'm confused as to why I can't do the same thing via JavaScript.
Basically, I have an open AI document and would like to duplicate its artboard and then move it to a new position(X axis, 50pixels away from the original). Doesn't seem too hard, but I can't figure it out. This is for CS5.
var docRef = app.activeDocument; var abSrc = docRef.artboards[0]; var abSrcX = abSrc.artboardRect[0];
[Code]...
Taking that into account if I add (1224 + 144) to abSrcX and abSrxW it creates another artboard 2" away from the previous at 17" x 11". If I want to run it again, I just to add (1224 + 144) to abSrcX and abSrxW again. Now to figure out how to do this dynamically on the fly.
I'm trying to nudge the anchor points on an object randomly (to get an informal look). (I know some Effects do this already.)
Maintaining corner points is no problem - you just set the direction handles to the same coordinates as their anchor.
But I can't nudge a smooth point in the way I want to, which is to move the anchor but maintain the direction handles in exactly the same relation to their anchor as they had before. That is to say, they should remain smooth points.
My script calculates the difference between 'before' and 'after' positions of the anchor, and applies that difference to the direction handles… but in practice the smooth points are converted to corners, because the direction handles don't maintain their relation with the anchor.
var docRef = activeDocument; var objects = activeDocument.selection.length; var cShift = prompt("Point shift (pt)",5); // loop through all objects for(var count=0;count<objects;count++)
I was hoping to create a JS script to move objects away from common center based upon their current position. I was thinking to use a single selected path item as the center based on its position x/y and width/height. Using this reference point the script would then move away all other path items from this center point based on a desired amount and with uniform increments given their current location from this center. I was thinking cos and sin would be my friend in this case, however they seem to have become my foe instead. ;-)
Does this sound doable? What am I missing, doing wrong, misinterpreting? Below is a non-working attempt, I can't seem to sort things out, perhaps I was close and missed it or maybe I am super way off and its more complex than I thought. However at this point I am confused across my various failed attempts this only being one of them.
// Example failed code, nonworking concept var docID = app.activeDocument; var s0 = docID.selection[0]; pID = docID.pathItems; var xn, yn; var stepNum = 20;
Is it possible to script using a highlighted layer.
I know that selected items can be used for scripting, but I would like to just highlight the layers I want to process but not directly select the items on those layers.
I am realtively good with actionscript, so I am trying my hand at this to streamline our image exporting process. I am using CS5 on a PC.
We build our illustrator files to be a combination of different layers. Sometimes just one layer is exported at a time, and sometimes layers are combined to form a more complex image. We use layer names with instructions of what layers should be on and off.
An example of the layer naming might look like this:
03 (01-ON, 02-OFF) 02 (01-OFF) 01
I have been able to figure out how to check if there is a note to turn a layer on, my question is how do I select the layer to turn on the visibility without using the exact name of the layer?
In my example, when layer 3 gets exported, it should have layer "01" visible and layer "02 (01-OFF)" not visible. Since our files are always constructed differently (meaning 02 might not always have a note about 01 being off), I can't use the getByName option because I don't have an exact name to call the layer and turn the visibility on. The layers always start with 01, 02, 03, etc. Is there a way to use getByName and only have it look at the first 2 characters of the layer name?
I'm new in scripting and i need to make a script that moving all layers into a single layer (in Illustrator i press CTRL+A then CTRL+G in layers and works) but i need that in script.
It does almost what I need it to do. except that it also copies the ".ai" in to the layer name. Is there some way to modify this script to have it exclude or delete the file extension?
I am trying to iterate through objects in a layer and if the object satisfy a condition, I want to remove it.
Problem is that from what I suspect, if I use a "for loop" then when I remove an element, the initial length of the loop becomes invalid by removing the element. So what I would need is to iterate through objects in another matter and I am clueless.
I have a PDF file with 25 pages that I need to get into the form of an Illustrator file with 25 layers. I found the example of opening a particular page of a PDF file (using CS6), and that works. And I can create layers. But I can't figure out how to place a particular page of a PDF file into the new layer. Where/how do I provide the page info?
(I have a PostScript program that generates artwork for signs that are to be laser etched at the TechShop. The laser interface uses Illustrator and a special Print driver. I notice that opening a page from a PDF file positions the contents slightly differently than placing that page, when I do it manually, so I figured I'd create the multilayered Illustrator file by opening one page (which works) then placing all the pages in their own layers, then deleting the first page. Then the positioning will be consistent. But I'm stuck at placing a PDF page...)
tell application "Adobe Illustrator" to activate
-- This function opens the file passed as -- a file reference parameter, at page myPage. -- fileToOpen is a reference to a multi-page PDF file -- and needs to be set up before calling this function.
on openMultipageFile(fileToOpen, myPage) tell application "Adobe Illustrator" set user interaction level to never interact
I'm trying to build a map of the world that includes provinces and sub-provinces (counties). I will be animating it in AE. AE only sees the top layers so it is imparative that the name of the top layer corresponds the the correct province. Unfortunately all the provinces are not layers. They are objects. I can use the "Release to Layers" command to get all objects nested into top level layers. But the top level layers have generic names (Layer 1, Layer2, Layer 3). The objects nested within these layers have the correct name.
Is there a script that will rename the top level layer using the name given to the object nested within that layer? If not, how to create one?
Here's a link to one of the files: world_all_provinces_Senegal divisions. Level 1_area.zip
Are there any scripts to find and replace layer names?
There is an excellent script available for Photoshop which allows you to not only replace words in layer names, but also insert words as Prefixes, Suffixes and Sequential Numbers. The illustrator version of this script only allows sequential numbering: It doesn't offer find and replacing of words.
Ideally, it would be great if there was something that could do multiple find and replaces in one go:
(E.g. You have layers like this Car, Dog, Bat You enter: car(Option1), dog(Option2), Bat(Option3) Your layers then become: Option1, Option2, Option3). )
I recently created a script that reads the layer names of an Illustrator file, and uses the name to identify a swatch to use to pattern all elements on that specified layer. The script works well, and is a real time saver for our mapping staff, but it requires duplicate swatches to exist, where the only difference is their colour.
To improve the script I want to duplicate a swatch and modify its' colour before applying it to a specific layer. I think the only way this can be done is via the "placedItems" command. So the code I'm trying to write looks likke this:
for(var s=0; s<slib.length; s++){ // search swatch library var pat=slib[s].name; // get swatch name
[Code]...
However I'm struggling to find the correct syntax to make this work.
I'm looking to create a script to batch rename a number of artboards.
- I have 100 named layers.
- I have 100 artboards.
- I would like to rename the artboards to match the layer names.
- The layers are organized in the same descending orderas the artboards (ignoring the actual artboard names*).
- The topmost artboard (1 in the list) would be renamed "newspaper", the second artboard would be renamed "typewriter", the third artboard would be renamed "books", etc.
*in the example below the artboard named "Artboard 7" is actually the 6th artboard in list.
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.
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? URL....