The layer name must include

Hello

I'm trying to find the objects of magenta color applied. The code below works fine. But I need to write the name of layer error in the alert object.

var pageLen = app.activeDocument.pages.length 
var mag=0
for(i=0;i<pageLen;i++)
{
        var pageItemLen = app.activeDocument.pages.item(i).pageItems.length 
        for(j=0;j<pageItemLen;j++)
        { 
            color = 0; scolor =0
            if(app.activeDocument.pages.item(i).pageItems.item(j).fillColor.name != "None")
                color = app.activeDocument.pages.item(i).pageItems.item(j).fillColor.colorValue
            if(app.activeDocument.pages.item(i).pageItems.item(j).strokeColor.name != "None")
                scolor = app.activeDocument.pages.item(i).pageItems.item(j).strokeColor.colorValue
            if(color == "0,100,0,0" || scolor == "0,100,0,0")
                  mag=1
           }
    }


if(mag==1)
{
          alert("ERROR: Some Page ojects contain Magenta color fill/stroke")
    }
                else{
                 alert("Page ojects not contain Magenta color fill/stroke")
}

I am bit confused how to add it. Please help me?

Kind regards

Kitty

It is likely that your variable myLayer hosts only the last occurrence of layer name.

You must store all possible values in a table.

var pageLen = app.activeDocument.pages.length
var mag=0;
var myLayersArray = [];

for(i=0;i 
         

Tags: InDesign

Similar Questions

  • Select the layer name

    I need to select a specific layer or group by name.  What is the correct syntax to do this with Javascript?

    you want to select all the items on the layer? or only some types (e.g., blocks of text, groups, paths)?

    Let's take a look at the same time.

    Let's start by selecting all the elements on a given layer (in this case the layer is called "Target layer");

    Note that pageItems means that any element of art in the document. could be text, could be a path, can be a group, could be a compound path.

    var docRef = app.activeDocument;
    var layers = docRef.layers;
    var myLayer = layers["Target Layer"]; //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(var a=0;a
    

    now lets do the same thing, but we will choose just the groupItems

    var docRef = app.activeDocument;
    var layers = docRef.layers;
    var myLayer = layers["Target Layer"];
    
    docRef.selection = null;
    for(var a=0;a
    

    and finally, in order to be comprehensive, allows to select two different types of art objects, but not all types. For example, if a single layer has text blocks, groups, paths and transparent traces. Let's just select managers of related texts and groupItems. This time we will have to include a conditional statement to find the correct item types.

    var docRef = app.activeDocument;
    var layers = docRef.layers;
    var myLayer = layers["Target Layer"];
    
    docRef.selection = null;
    for(var a=0;a		   
  • I can't get rid of the layer names in the general properties tab layers PCB Ultiboard

    A bunch of DXF layer names have been concluded by Ultiboard 10.1 error a few years during a DXF for import operation. I have recently updated to 12.0 and hope that the old layers would be eliminated. I wanted to get rid of them for a long time. I tried to delete the file ub_config in AppData, but it didn't remove them. Is that all you can think to extract them from the clutches of the program? Thanks, Tod

    Hi Tod,

    I suspect one of your design files is the cause.  If you go to Options > CFP properties > general Layers, you see here DXF layers?  If you see the layers, you can select it and then press the delete button?

  • How to get the ID of the layer name layer?

    Hello everyone.

    Trouble with the implementation of a small script.

    I want to add to each of the selected layers in the Document a new layer with the image, make sure that the top of each layer.

    I think what I need:

    1. create a table of the layers selected by the user (necessarily by name)

    2. Select the image;

    3. pass by the table to create a layer, put in new picture selected layer and move the table above this layer.

    Found an example where the table is created on the index, but in my case it's not that - after that each addition of a new layer index is changes. How can I get the index of the layer by name?

    Andy_Bat1 wrote:

    But if I understand correctly, I need to know the ID or Index of the layer?

    No, you need a layer object (or layerSet). You can make reference to an object layer in several ways. The excerpt you posted has two, one is owned by activeLayer and the second is by index. You can also make a reference using the name of the layer and some methods like ArtLayers.add () return an object layer. The DOM is not an ID of the layer property.

    app.activeDocument.activeLayer.move (activeDocument.artLayers.getByName ('top'), ElementPlace ment. PLACEBEFORE);

    app.activeDocument.activeLayer.name = 'new top ";

  • A Script to find and replace the layer names

    Is there scripts to find and replace the names of layers?

    There is an excellent script available for Photoshop that allows you not only to replace words in layer names, but also insert words as prefixes, Suffixes and sequential numbers.

    The version of the illustrator of this script allows only sequential numbering: it does not offer search and replace words.

    Ideally, it would be great if there were something that could find multiple and replaces in a go:

    (for example

    You have layers like this car, the dog, the bat

    You enter: because (Option1), dog (Option2), Bat (Option3)

    Your layers become then: option 1, option 2, Option3).

    )

    Big_SmiLe, which is a very good start! Step 1 of learning how to Script is indeed, by adjusting an existing simple script to make things more complicated. (And usually then "break something", which is also a necessary part of the process.)

    You are right your comment, it comes to repetitive things. For one or two different articles that wouldn't be a problem, but in the longer lists you are soon lost.

    As usual to work with lists of search - replace is to build a table:

    var layernames = [
    [ 'FHairBowlBoy *Hair', 'Hairboy1' ],
    [ 'FHairCurlyafroBoy *Hair', 'Hairboy2' ],
    [ 'FHairSpikyBoy *Hair', 'Hairboy3' ],
    ];
    

    The general idea is to loop through all the names, check if the current layer name is "layernames [i] [0]" (the left column) and if so, rename it "layernames [i] [1]" (the right column). If you know how to write a loop in Javascript, then you can implement this immediately.

    However...

    A more advanced method to do this didn't need even loop on all layernames - instead you can immediately 'get' the correct name by layer! It's magic! Almost!

    The trick is to use a Javascript object rather than a table. JavaScript objects are nothing special; "Layers" of Illustrator are an array of objects, and each object 'sex' has a 'name' property, which you can read and set the value. What I do here, is to create a new object, where the part 'name' is the name of the original layer and its value is the name of the new layer. All you need to check each layer is if there is a "object.originalLayerName" property and if so, assign its value to this layer name.

    It looks a bit like the table above, except that (1) you use {.} instead of [..] to create an object and (2) you add pairs "name: value" instead of 'value' only (in fact, the 'name' of a value in a table is simply her number).

    So here's what it looks like:

    // JavaScript Document
    var doc = app.activeDocument;
    // name indexed object
    var layernames = {
     'FHairBowlBoy *Hair':'Hairboy1',
     'FHairCurlyafroBoy *Hair':'Hairboy2',
     'FHairSpikyBoy *Hair':'Hairboy3'
    };
    // loop through all layers
    for (var i = 0; i < doc.layers.length; i++)
    {
     //Set up Variable to access layer name
     var currentLayer = app.activeDocument.layers[i];
     if (layernames[currentLayer.name])
     {
      currentLayer.name = layernames[currentLayer.name];
     }
    }
    

    Enjoy!

  • I can't change the layer names

    Even if I double click on the names. The layers are not locked. I never had this problem in cs5.

    Hello!

    You should be able to just double click and rename your layer, as shown below.

    Since you said it does not work for you: with the layer is highlighted, go to layer > layer rename. This will allow you to rename your layer.

    Please post if you have any questions,

    Janelle Flores

  • Keep the layer names when describing the text

    I would like to know if there is a way to keep the names of the objects/layers of text when the text is converted to text outline, using scripts.

    I create files with dozens of text layers (player names on the back of the jerseys of sport) and send the .ai file to manufacturers. This means that I have to expose the text, but when I do, the layers all lose their names and everything becomes "< Group >.

    Can anyone think of a way of naming these layers with the text they contain?

    Hi openbracket,.

    It is impossible, if the text is underlined.

    But it is possible for the text and the outline of the text via script (don't forget that the selected text is only filled with no effects or stroke)

    You can try something like this:

    // required: an opened document with one selected text frame
    var aDoc = app.activeDocument;
    var aSel = aDoc.selection;
    if (aSel[0].typename =="TextFrame") {
        if (aSel[0].characters.length < 40) {
        var newName = aSel[0].contents;
        } else {
        newName = aSel[0].contents.substr(0, 39);
        }
    aSel[0].createOutline();
    aSel = aDoc.selection;
    // name of the new Group = contents or part of contents of selected text frame
    aSel[0].name = newName;
    }
    

    Have fun

  • Script to make the list of layer names.

    I wonder if someone could help me make the simple script that take the layer names and the list of their share on the A4 in canvas.

    Now I just got the screenshot of the list of Illustrator and edit it through photoshop to print, but it is too small, because each file have a approximately 25-50 layers.

    Looks like this:

    layer-list.jpg

    I tried to edit the script of John Wundes, which makes the list of the nuances, but it seems difficult for my skills.

    /////////////////////////////////////////////////////////////////
    // Render Swatch Legend v1.1 -- CS, CS2, CS3, CS4, CS5
    //>=--------------------------------------
    //
    //  This script will generate a legend of rectangles for every swatch in the main swatches palette.
    //  You can configure spacing and value display by configuring the variables at the top
    //  of the script. 
    //   update: v1.1 now tests color brightness and renders a white label if the color is dark.
    //>=--------------------------------------
    // JS code (c) copyright: John Wundes ( [email protected] ) www.wundes.com
    // copyright full text here:  http://www.wundes.com/js4ai/copyright.txt
    //
    ////////////////////////////////////////////////////////////////// 
        doc = activeDocument,
        swatches = doc.swatches,
        cols = 4,
        displayAs = "CMYKColor",  //or "RGBColor"
        rectRef=null,
        textRectRef=null,
        textRef=null,
        rgbColor=null,
        w=150;
        h=100,
        h_pad = 10,
        v_pad = 10,
        t_h_pad = 10,
        t_v_pad = 10,
        x=null,
        y=null,
        black = new GrayColor(),
        white = new GrayColor()
        ;
    
    
        black.gray = 100;
        white.gray = 0;
    
    
    activeDocument.layers[0].locked= false;
    var newGroup = doc.groupItems.add();
    newGroup.name = "NewGroup";
    newGroup.move( doc, ElementPlacement.PLACEATBEGINNING );
    
    
    for(var c=0,len=swatches.length;c<len;c++)
    {
            var swatchGroup = doc.groupItems.add();
            swatchGroup.name = swatches[c].name;
           
            x= (w+h_pad)*(c% cols);
            y=(h+v_pad)*(Math.floor((c+.01)/cols))*-1 ;
            rectRef = doc.pathItems.rectangle(y,x, w,h);
            rgbColor = swatches[c].color;
            rectRef.fillColor = rgbColor;
            textRectRef =  doc.pathItems.rectangle(y- t_v_pad,x+ t_h_pad, w-(2*t_h_pad),h-(2*t_v_pad));
            textRef = doc.textFrames.areaText(textRectRef);
            textRef.contents = swatches[c].name+ "\r" + getColorValues(swatches[c].color) ;
            textRef.textRange.fillColor = is_dark(swatches[c].color)? white : black;
            //
            rectRef.move( swatchGroup, ElementPlacement.PLACEATBEGINNING );     
            textRef.move( swatchGroup, ElementPlacement.PLACEATBEGINNING );
            swatchGroup.move( newGroup, ElementPlacement.PLACEATEND );
    }
    
    
    function getColorValues(color)
    {
            if(color.typename)
            {
                switch(color.typename)
                {
                    case "CMYKColor":
                        if(displayAs == "CMYKColor"){
                            return ([Math.floor(color.cyan),Math.floor(color.magenta),Math.floor(color.yellow),Math.floor(color.black)]);}
                        else
                        {
                            color.typename="RGBColor";
                            return  [Math.floor(color.red),Math.floor(color.green),Math.floor(color.blue)] ;
                           
                        }
                    case "RGBColor":
                       
                       if(displayAs == "CMYKColor"){
                            return rgb2cmyk(Math.floor(color.red),Math.floor(color.green),Math.floor(color.blue));
                       }else
                        {
                            return  [Math.floor(color.red),Math.floor(color.green),Math.floor(color.blue)] ;
                        }
                    case "GrayColor":
                        if(displayAs == "CMYKColor"){
                            return rgb2cmyk(Math.floor(color.gray),Math.floor(color.gray),Math.floor(color.gray));
                        }else{
                            return [Math.floor(color.gray),Math.floor(color.gray),Math.floor(color.gray)];
                        }
                    case "SpotColor":
                        return getColorValues(color.spot.color);
                }    
            }
        return "Non Standard Color Type";
    }
    function rgb2cmyk (r,g,b) {
     var computedC = 0;
     var computedM = 0;
     var computedY = 0;
     var computedK = 0;
    
    
     //remove spaces from input RGB values, convert to int
     var r = parseInt( (''+r).replace(/\s/g,''),10 ); 
     var g = parseInt( (''+g).replace(/\s/g,''),10 ); 
     var b = parseInt( (''+b).replace(/\s/g,''),10 ); 
    
    
     if ( r==null || g==null || b==null ||
         isNaN(r) || isNaN(g)|| isNaN(b) )
     {
       alert ('Please enter numeric RGB values!');
       return;
     }
     if (r<0 || g<0 || b<0 || r>255 || g>255 || b>255) {
       alert ('RGB values must be in the range 0 to 255.');
       return;
     }
    
    
     // BLACK
     if (r==0 && g==0 && b==0) {
      computedK = 1;
      return [0,0,0,1];
     }
    
    
     computedC = 1 - (r/255);
     computedM = 1 - (g/255);
     computedY = 1 - (b/255);
    
    
     var minCMY = Math.min(computedC,
                  Math.min(computedM,computedY));
     computedC = (computedC - minCMY) / (1 - minCMY) ;
     computedM = (computedM - minCMY) / (1 - minCMY) ;
     computedY = (computedY - minCMY) / (1 - minCMY) ;
     computedK = minCMY;
    
    
     return [Math.floor(computedC*100),Math.floor(computedM*100),Math.floor(computedY*100),Math.floor(computedK*100)];
    }
    
    
    function is_dark(color){
           if(color.typename)
            {
                switch(color.typename)
                {
                    case "CMYKColor":
                        return (color.black>50 || (color.cyan>50 &&  color.magenta>50)) ? true : false;
                    case "RGBColor":
                        return (color.red<100  && color.green<100 ) ? true : false;
                    case "GrayColor":
                        return color.gray > 50 ? true : false;
                    case "SpotColor":
                        return is_dark(color.spot.color);
                    
                    return false;
                }
            }
    }
    

    arop16461101,

    something like that?

    var theLayers = app.activeDocument.layers;
    var str = new Array ();
    for (i = 0; i < theLayers.length; i++) {
        str.push (theLayers[i].name)
        }
    var tF = theLayers[0].textFrames.add();
    tF.contents = str.join ("\r");
    alert("new text frame with layerlist added on layer " + theLayers[0].name);
    

    Have fun

  • for loops with the name of the layer.

    I developed a script that checks if the layer color-101 exists in an open document.

    If the layer color-101 exists executes the block of code on layer color-101.

    If the layer color-101 are not running action Add layer color-101.

    Back at the beginning of the loop to check again

    I do it with a loop for and if statement.

    1. Why does the loop not stop when the loop count variable corresponds to the layer color-101 name variable?

    2. how the loop can return to the beginning to check again the presence of color-101 layer?


    Variable decalre

    app.activeDocument = docRef;

    var theLayer = "color-101;

    loop through the layers

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

    the layer name corresponds to the loop variable

    If (docRef.layers [i] .name == theLayer) {}

    Execute the block of code for layer color-101

    Alert ("Layer" + theLayer + "exist.");

    }

    }

    layer color-101 was not found, enforcement action Add layer color-101

    Alert ('The' + theLayer + "' there is no layer: Run Add layer color-101 action. '");

    back at the beginning of the loop and check again


    Your loop does not actually stop to find the right layer. He is content to display the alert popup window, then continues. Also the 'not found' - part will still raise. And the comparison must be 100% equal without difference case or spaces or 'copy 12' - suffixes.

    Try something like

    Declaring variables

    app.activeDocument = docRef;

    var layer_found = false;

    loop through the layers

    for (var i = 0; i)< docref.layers.length;="">

    var layer = docRef.layers [i]

    If (Layer.Name.toLowerCase (). IndexOf("case-101") > = 0) {}

    Alert ("found layer:" + layer.name);

    layer_found = true

    do what needs

    }

    }

    If (! layer_found) {}

    Alert ("Layer not found!");

    do what needs

    }

  • Copy the name of the layer to the Clipboard?

    Hi, I was looking for a way to copy the name of the active layer in the Windows Clipboard, I hope this a quick solution. What I managed to do up to now, it is to open the Layer Properties dialog box, and then press 'CTRL + C' to copy the layer name (because the name of the layer is already highlighted at this stage), and then it correctly copy the name of the layer in the Windows Clipboard.

    But I found that when the system is under load, the Layer Properties dialog box is sometimes slow to open, and despite this, it seems that it is an additional step that could be eliminated.

    I searched through keyboard shortcuts and also in all the menus layer for a keyboard shortcut for just 'copy layer to the Clipboard name' but cannot find anything.

    Anyone know if there is a quick shortcut to do this or maybe a quick script that will copy just the name of the layer?

    Thanks in advance...

    Bingo! Thank you Philippe/csuebele/pixxxel, it's the "clip.exe" that was the problem for me. I pasted in system32 and now it works. It's awesome - now I am able to view a tool tip with the name of the layer, whenever I change the layers (with the help of my other app left 3rd) - this is especially useful when working in mode full screen when you don't see the palette layers. It will update your tool tip with the name of the layer whenever you use keyboard shortcuts to select the different layers.

    If someone thinks they would find useful, I had me more than happy to share it... but it's using a different script software, so I may or may not be able to talk about it here. Shoot me a private message if I can't talk about it here and you would like it to be.

  • Changing the text does not update the name of the layer.

    With Win7 and CS5.

    I just noticed something with my text in CS5 that differs from the CS3 and also for me, a step back.

    I made a text layer with words.  The words appeared as the layer name in the layers palate (I typed 'TEXT' on the screen and the text layer is named text for example).

    Then I double-clicked on the text icon and this field selected the word on the screen.  Then, I changed the word 'TEXT' for some other say word "WORD".  However, this new Word I typed in was not carried over to the name of the layer so the ancient name of the layer remained.

    In CS3, the name of the layer is updaed when the words on the screen are changed.

    I really want the new text update on the name of the layer.  Is it possible to fix this or is it just something in my system.

    Thanks in advance.

    JohnRich

    I just tested with Photoshop CS5 and CS6, and layer update for me names when I edited the text.  I have not configured something specific that causes.

    -Christmas

  • After effects pre composed the whole MVI_0000.MOV instead of just the LENGTH of the LAYER?

    Hey guys

    I'm working on a project in AE that involves the green screen.

    I'm having a problem with the COMPOSITION of PRE. Please keep in mind that I have done about 0 video and HAVE NOT suffered this problem so far.

    Now, whenever I try to compose Pre pictures green screen, after effects Pre composed the whole MVI_0000.MOV instead of just the DURATION of the LAYER.

    Thus forcing me to do things the long extreme way to find my points IN and OUT, that I'm afraid to do for audio, reason for synchronization.

    I feel like a one hit shortcut keyboard or something because I have not had to deal with this issue all the time I've been editing.

    I tried the things:

    removal of the preferences.

    Open a new project

    uninstalling / reinstalling AE

    software update

    analysis diagnosis by computer

    And yet nothing has worked... Does anyone else have this problem?

    Suite CS6

    MAC PRO

    the "Adjust composition duration the duration of the selected layers to ' in the dialog of Pre-composed was only introduced in CC if you CS6 and that you want to dial prior to the duration of the layer, you must take the long road that is:

    1. your layer should be cut like that

    2. While the layer is selected, you type Cmd + Alt + B so the work area be cut to the layer like this:

    3. you dial before with these settings:

    4. in your demo, you right-click on the work area and select "Trim Comp to work Area"

    5. you return to your master comp and feel happy with what you have done

  • Necessary emergency with a request: fill date of prior art on the column name

    Hello

    Can you please help me with the query. I would be grateful for your time and your help.

    I have the query and the following output. Basically, the query selects a date, a table and counties received documents based on the current date, day-1, - 2 days-, 3 days-4 days-5 days and especially 5 days. It's the query I wrote. Now the requirement has slightly changed and described below.

    Current query:

    SELECT SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 0 PUIS 1 AUTRE 0 FIN) Zéro ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 1 PUIS 1 AUTRE 0 FIN)   One ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 2 PUIS 1 AUTRE 0 FIN) Two ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 3 ALORS 1 SINON 0 FIN) Trois ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() = 4 PUIS 1 AUTRE 0 FIN) Quatre ,

    SUM (BOX WHEN TRUNC (SYSDATE) TRUNC (File_Date) = 5 THEN 1 ELSE 0 END) Five ,

    SUM (CASE WHEN TRUNC (SYSDATE) TRUNC ( )File_Date() > 5 PUIS 1 AUTRE 0 FIN) OverFive ,

    COUNTY (*) Total

    DE DOCUMENT_TABLE

    OUTPUT:

    Zero

    One

    Two

    Three

    Four

    Five

    More than five

    Total

    3

    6

    3

    6

    10

    50

    100

    178

    Now the desired output:

    The column name must be the date, for example the column name, we're Sysdate, two column name is Sysdate-1 day and the result would look like:

    OUTPUT:

    17/12/2014

    16/12/2014

    15/12/2014

    14/12/2014

    13/12/2014

    12/12/2014

    More than five

    Total

    3

    6

    3

    6

    10

    50

    100

    178

    Hi, just try below as you say it's urgent

    Select sysdate, sysdate-1, sysdate-2, sysdate-3,-4, etc of daul sysdate

    Union

    your query

    (you must ensure for the same type of data)

    are you using oracle report or just in the sql query. If the reports, then you can manage very easily with the introduction of a formula column.

  • Script to rename work with layer names plans

    I want to create a script to rename lots a number of work plans.

    -J' have 100 named layer.

    -J' have 100 work plans.

    -I would like to rename work plans to match the layer names.

    -Layers are organized in the same descent orderas work plans (ignoring the names real artboard *).

    -The plan of work in the foreground (1 in the list) would be renamed "Journal", the second plan of work would be renamed "typewriter", the third work plan would be renamed "books", etc..

    * in the example below, the artboard named 'Graphic Board 7' is actually the 6th work plan in the list.

    LayerNames-To-Artboards.png

    Any help would be wonderful.

    Hi sensibleworld, welcome to the forum.

    For your case, it should be fairly simple. The following excerpt from script bit renames work plans to match the corresponding layer names that you described in your first post above. It only works if the number of layers and work plans correspond to such indicated and talked about in your above description of requirements.

    if (app.documents.length == 0) {
        alert("No Open / Active Document Found");
    } else {
        var doc = app.activeDocument;
        if (doc.artboards.length == doc.layers.length && doc.layers.length == doc.artboards.length) {
            for (var i = 0, l = doc.artboards.length; i < l; i++) {
                var ab = doc.artboards[i];
                ab.name = doc.layers[i].name;
            }
            alert("Finished:\nRenaming of Artboards to match Layer names is complete");
        } else {
            alert("Opps: This wont work!\n The number of Layers and Artboards do not match");
        }
    }
    

    I hope that this is useful for your efforts and your requirements. Welcome back to the forum.

  • The layer properties. Visible, but unprintable

    Hello

    I have a PDF file with layers. I want some of that time to be visible but not printable. Is this possible?

    Thank you

    Yes, it is perfectly possible. Right-click on the layer name in Acrobat, and choose Properties. Then you have the visibility controls, printing and exporting.

Maybe you are looking for