Script that selects specific color coded layer?

Hi Guys, does anybody knows how to find a layer in the layers palette using its color coding ?
I've did this action for Photoshop for stacking layers on top of each other,basically it aligns one
layer to another regardless of their position and size.Here is a demo how it works:  http://vimeo.com/13713886
The action searches for the target layer via its specific name, using a simple .jsx script.This way the layer order in your document doesn't matter.However I don't want the action to rely on layer name either and was thinking that It can find the layer via its color coding
I would be really glad if someone can write a script that searches trough all the layers in the layers palette and selects the color coded one.
Thank you.

This should do it...
selectAllLayers();
var selectedLayers =  getSelectedLayersIdx();
for(var a=0;a< selectedLayers.length;a++){
    makeActiveByIndex( selectedLayers[a], false );
    if(colourMarkedLayer()) break;
function selectAllLayers() {
activeDocument.activeLayer = activeDocument.layers[activeDocument.layers.length-1];
if(activeDocument.activeLayer.isBackgroundLayer)
activeDocument.activeLayer = activeDocument.layers[activeDocument.layers.length-2];
var BL = activeDocument.activeLayer.name;
activeDocument.activeLayer = activeDocument.layers[0];
    var desc5 = new ActionDescriptor();
        var ref3 = new ActionReference();
        ref3.putName( charIDToTypeID('Lyr '), BL);
    desc5.putReference( charIDToTypeID('null'), ref3 );
    desc5.putEnumerated( stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelectionContinuous') );
    desc5.putBoolean( charIDToTypeID('MkVs'), false );
    executeAction( charIDToTypeID('slct'), desc5, DialogModes.NO );
function getSelectedLayersIdx(){
      var selectedLayers = new Array;
      var ref = new ActionReference();
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
      var desc = executeActionGet(ref);
      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
         desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
          var c = desc.count
          var selectedLayers = new Array();
          for(var i=0;i<c;i++){
            try{
               activeDocument.backgroundLayer;
               selectedLayers.push(  desc.getReference( i ).getIndex() );
            }catch(e){
               selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
       }else{
         var ref = new ActionReference();
         ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
         ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
         try{
            activeDocument.backgroundLayer;
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
         }catch(e){
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
      return selectedLayers;
function makeActiveByIndex( idx, visible ){
    var desc = new ActionDescriptor();
      var ref = new ActionReference();
      ref.putIndex(charIDToTypeID( "Lyr " ), idx)
      desc.putReference( charIDToTypeID( "null" ), ref );
      desc.putBoolean( charIDToTypeID( "MkVs" ), visible );
   executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
function colourMarkedLayer(){
   var ref = new ActionReference();
   ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
   var appDesc = executeActionGet(ref);
   if(appDesc.getEnumerationValue(stringIDToTypeID('color')) != 1315925605) return true;
   return false;

Similar Messages

  • HELP !  why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !

    HELP !  why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !
    what am i missing ??!!

    Please add you system info and SpeedGrade version and build number if you actually want help.

  • Simple script that will export the coordinates (layer bounds - top left x,y)

    Hi,
    I'm looking for a simple script that will export the coordinates (layer bounds - top left x,y) of the layers to an seperate xml/txt file.

    Your screen capture looks like it's from Photoshop.
    In InDesign sub layers are page items, the containing layer has no dimension. So you could get all the page item's x, y, width, height. But you might have to consider groups and then the layering could be very complex. The stacking order could also get complex. Page items have an index, but it's relative to its parent container.

  • Script that gives specific names to layers - from bottom to the top

    Hi,
    This is probably an easy one for anyone with JavaScript experience.
    I have 35 layers that I want to give specific names to (now they're named liked "layer 1, 2, 3" - but sometimes this won't be consistent, so some numbering might be skipped,
    in other words I can't rely on a script that renames a specific "Layer 1" to "my name").
    I want to rename each layer from the bottom to the top, i.e.:
    "Power"
    "Yellow"
    "Hello"
    With the script working its way up from the bottom to the top.
    How do I accomplish this?
    Thank you so much for you taking your time to help me.

    something like this?
    if so, type your names in a text frame, select it and run this script
    // rename Layers from the bottom up
    // carlos canto
    // https://forums.adobe.com/thread/1653162
    // type your names in a text frame, select it and run this script
    var idoc = app.activeDocument;
    var itext = idoc.selection[0];
    var a_names = itext.contents.split ('\r').reverse();
    var namecount = a_names.length;
    var layercount = idoc.layers.length;
    var counter = Math.min(namecount, layercount);
    for (i=layercount-1, j=0; i>=layercount-counter; i--, j++) {
        var ilayer = idoc.layers[i];
        ilayer.name = a_names[j];

  • How to make it so that DW shows color-coded text for a file type?

    Hi,
    I work with ".inc" files, which I include into PHP files.
    At the moment DW just shows all of the text within .inc files
    as black. How can I get DW to color-code the text (like it does
    with other files such as html or php) so that I can make it easier
    to read?
    Cheers!

    http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_16410
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "chuckee" <[email protected]> wrote in
    message
    news:fb6cdb$mno$[email protected]..
    > Thanks for that but I did want to keep the file with the
    .inc extension.
    > In the back of my mind I thought there was some setting
    I could change so
    > that DW recognised new file types.

  • Select all paths of a specific color in one document

    Hi,
    I'm on Illy CS2, windows xp.
    I want to open a doc, run a script that selects all paths of a color, say 255,0,0 or 50,0,20,4 and changes that color to black or another color I specify and also changes the stroke. Is this possible? I can't see how i would do it?
    Thanks in advance,
    Stan

    Unfortunatly there is no getByColor method - below is a clunky way to get an array of objects that match a provided CMYK color : <br /><br />// Color you want to match<br /><br />myColor = new CMYKColor();<br />myColor.black = 50;<br />myColor.cyan = 0;<br />myColor.magenta = 0;<br />myColor.yellow = 0;<br /><br />foundObjects = getSameColor("ALL",myColor);<br /><br />function CMYKMatch(control,test)<br />{<br />     if (test.black == control.black && test.cyan == control.cyan && test.magenta == control.magenta && test.yellow == control.yellow)<br />     {<br />          return true;<br />     } else { <br />          return false;<br />     }     <br />}<br /><br />function getSameColor(type,color)<br />{<br />     var results = new Array();<br />     if (type != "FILL" || type != "STROKE" || type != "ALL")<br />     {<br />               myArt = app.activeDocument.pageItems;<br />               for(var i = 0; i<myArt.length;i++)<br />               {<br />                         if (myArt[i].typename != "TextFrame") <br />                         {<br />                              if (type == 'FILL' || type == 'ALL') {<br />                                   if (CMYKMatch(color, myArt[i].fillColor)) { results.push(myArt[i]); }<br />                              }<br />                              if(type == 'STROKE' || type == 'ALL') {<br />                                   if (CMYKMatch(color,myArt[i].strokeColor)) { results.push(myArt[i]); }<br />                              }<br />                         }     <br />               }<br />     }<br />     return results;<br /><br />}

  • Navigation and Color Coding

    Hello Guys,
    I have got couple of design questions.
    1. I have a report with a view selector on it(Annual, quarter, month) that navigates to another report with the same view selector(annual quarter month) The problem I have is with the navigation landing pages.
    When i changed my report to quarter view from the annual view and then navigate to the report B I still land in ANNUAL view as that is the first view of the report. Users expect to land on quarter view directly based on what they select on the report A.
    So i was wondering if there is a way to control the view selector and column selector landing pages when navigation from report A to report B.
    2. This is regarding Color coding. I have three columns in my report Year, quarter, month with conditional color coding done on it(when year=09 then red, when month =jan then blue some thing like that). So now the report has both table and pivot view. The users want to see the color coding only on pivot but not on table. Is there a way to achieve that? I tried duplicating the columns and hiding in the table but hiding in the table will hide across all the views. So i am kind of stuck there as well.
    Can we control this?
    Any advice is appreciated
    thanks
    Prash

    Regarding 2) don't know how feasible this is since I can't see your report, but you can try this:
    1) For the columns that you want color-coded, put two instances in your Criteria mode. Now color code one each of those "dual columns" for your pivot table.
    2) For the "Table View" build another pivot table, but design it like a table, but this time using the "uncolor-coded" columns in that pivot table and keeping the other columns in the Excluded box.

  • Script to select patterns in Illustrator Document

    Kindly we need a script that select all pattern objects in the active document in illustrator.

    there you have an example.
    Did not tested, but this should do the job for you.
    Don't pay attention to adobe staff advices. They know nothing.
    #target illustrator
    var doc = activeDocument;
    var items = doc.pathItems;
    var fill = stroke = null;
    for (var i=0; i < items.length; i++) {
        fill = items[i].fillColor;
        stroke = items[i].strokeColor;
        if (fill == "[PatternColor]") items[i].selected = true;
        if (stroke == "[PatternColor]") items[i].selected = true;

  • Hello,  Is there a script that I can change all the colors of a layer in to 1 PMS color, unite every object and than give it an offset of -0,2 mm ?

    Hello,
    Is there a script that I can change all the colors of a layer in to 1 PMS color, unite every object and than give it an offset of -0,2 mm ?

    the offset has to be semi-automatic, apply an Offset Path Effect (by hand), create a Graphic Style out of it (by hand), then the script can apply this graphic style to objects.

  • Need script that delete objects of certain color...

    Hello. For my Hobby I would need an Illustrator script that can delete objects of a certain color on selected layer. The color can be set in a dialog like #000000 or anything alike.
    I will need it to delete letters in text that has a certain color (different than letters around it). Letters to delete can be inside sentances or free. It doesn't matter if the text need to be outlined and ungrouped before run script, or not.
    I would apprechiate any help. Thank you.

    // CharacterColorizedIfNotMatchPrompt.jsx
    // Hint: test the script with little text.
    // The more extensive the text, the more time it takes the script.
    // greetings pixxxel schubser
    // http://forums.adobe.com/thread/1190610?tstart=0
    var aDoc  = app.activeDocument;
    var col = new CMYKColor();
    col.cyan = 0;
    col.magenta = 20;
    col.yellow = 0;
    col.black = 0;
    var aTFrame = aDoc.textFrames;
    if (aTFrame.length > 0) {
        var check = prompt ("Which character?", "a");
        check1 = check;
        check2 = check1.toUpperCase();
        for (i=0; i<aTFrame.length; i++) {
            for (j=0; j<aTFrame[i].characters.length; j++) {
                aChar = aTFrame[i].characters[j];
                if (aChar.contents != check1 && aChar.contents != check2) {
                    aChar.fillColor = col;
    alert("done")
    Try this.
    Have fun.

  • Script to select same stroke color and apply a new swatch...

    I am trying to write a script that will select a line based on a swatch name, apply a new swatch, set the stroke, dash and miter of the line...and then create a new layer, change then name of the layer, and then move the selected items to the newly created layer.
    All I could seem to accomplish was renaming a swatch.
    var swatchName = app.activeDocument.swatches;
    if (swatchName.length > 0) {
        for (i=0; i < swatchName.length; i++){  
            changeName(swatchName[i]);
    function changeName(swatchObject){
                     if (swatchObject.name == "PANTONE Orange 021 C"){                     
                        swatchObject.name = "021 (Orange)";
                    if (swatchObject.name == "PANTONE Red 032 C"){                     
                        swatchObject.name = "032 (Red)";
    So the goal of what I would like it to do is look for all paths with the stroke color set to "PANTONE Orange 021 C" then have it change the swatch name to "021 (Orange)". After that apply the stroke, dash and miter. Create a new layer named "021 (Orange)". Then send all of the selected lines to that layer.
    PLEASE HELP AS I HAVE 200+ files to do this task to. Using a windows machine with CS3. Trying to write in javascript.

    This would be the way to rename 2 existing swatches… The GUI pallet can be a little sticky in updating but it works…
    #target illustrator
    var docRef = app.activeDocument;
    var a = docRef.swatches.getByName('PANTONE Orange 021 C');
    a.name = '021 (Orange)';
    var b = docRef.swatches.getByName('PANTONE Red 032 C');
    b.name = '032 (Red)';
    redraw();
    My mistake… Looks like this Jive stuff gave you an unwanted bump from nowhere? Didn't look at the date…

  • How do I select a color range like in Photoshop OR copy/move a layer into the mask of another layer?

    Hi there,
    I'm trialling Photoshop Elements and wanting to use a black and white (grey scale) layer that I've made as a mask in another layer and don't know how to do it in Elements.  In Photoshop, I'd do this (there maybe a better way in PS to do it, but I haven't discovered it yet)...
    Click the layer i've created that I intend to use as a mask
    Select All
    Copy
    select layer that I want the mask to be applied to
    click the Add Layer Mask button (at the bottom of the Layers window)
    click the mask icon so it is highlighted (and the image isn't)
    switch to Channels view
    highlith the Layer Mask beneath the R,G,B layers and make it visible
    Paste
    make it invisible again
    switch back to layers.
    This works and retains the full range of transparency for semi transparency and soft edges of the mask etc.
    Alternatively, I can select a Color Range, but that doesn't seem to be available in PS Elements.
    So, how do I achieve the same result in PS Elements?
    Thanks for your help
    Jonno

    Perfect!   Thanks very much R_Kelly.  That does exactly what I was hoping to do.
    Cheers
    Jonno

  • Script that create Layerset with name from layer?

    Hello!
    This should be easy for someone who know whet is doing so not me:P
    I want script to automatically create layerset from each selected layer, name it as that layer and place that layer in it
    I found old script that do that but only normal layer not linked or embeded, and I want to do it for all selected layers not only to one
    Can someone modify it a little to work little better? I have no idea how to do it and probably would take me like thousands hours or more
    thx
    #target photoshop
    main();
    function main(){
    if(!documents.length) return;
    var doc = activeDocument;
    if(doc.activeLayer.kind != LayerKind.NORMAL) return;
    var layerRef = doc.activeLayer;
    var layerSetRef = doc.layerSets.add();
    layerSetRef.name = layerRef.name;
    layerRef.move(layerSetRef, ElementPlacement.PLACEATEND);

    You could remove the line
    if(doc.activeLayer.kind != LayerKind.NORMAL) return;
    But it would only work with one selected Layer (and also on selected LayerSets).
    To handle more than one selected Layer (or all Layers) some changes would be necessary.

  • Is it possible to write a script that samples an anchor points underlying color and applies it?

    I was wondering if anyone with scripting knowledge for Illustrator can think of a script that would sample the underlying color of anchor points in a selected gradient mesh and apply it to them? I was just thinking of ways to speed up the process of creating a vector drawing based on a picture so that all you would have to do is model your mesh and then let the script apply the colors.
    Thanks

    no can do, there's no access to mesh point with scripting, sorry about that.
    have you tried Mesh Tormentor? it is free!!!, but I don't know if it will help with your problem
    http://www.meshtormentor.com/

  • VB Script That Detects if A Specific Excel File is Open

    Hi Guys,
    I'm trying to move away from Task Scheduler as my trigger for opening an Excel file. The problem there is it has a minimum of 5 min interval (I need at least 30 sec) and If the process of the initial instance of the Excel file is longer than the usual that
    after 5 min another instance executes it messes up my memory bandwidth. What I want is to use VB Script that first check if a particular Excel file is open if yes then wait for another 30 sec to check.
    Question: What is the right syntax/code for detecting a specific Excel file and loops every 30 sec. But I also want to be able to end the loop if I want to.
    Here is my current code:
    Gateway Timeout
    RequestURI=http://timeentry/
    Set Recordset = CreateObject("ADODB.Recordset")
    ConnString = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=PHMNWWKS027604; DATABASE=db_skusetup; " &_
    "UID=root;PASSWORD=; OPTION=3"
    'Check for Export Query'
    Recordset.ActiveConnection = ConnString
    exportSQL = "SELECT * FROM tb_queue_export WHERE request_status = 'Pending' ORDER BY request_id DESC LIMIT 1"
    Recordset.Open exportSQL
    Set objExcelExtract = CreateObject("Excel.Application")
    Set objWorkbookExtract = objExcelExtract.Workbooks.Open("C:\Users\ushuam00\Desktop\LAPTOP.xlsx")
    If objWorkbookExtract.ReadOnly then
    if Recordset.Fields(3) <> "" then
    end if
    end if
    test= MsgBox(Recordset.Fields(3),3,Recordset.EOF)
    Recordset.Close
    ReadOnly is not doing it for me. 

    The only way to test it is to open it. Just open writable and, if the file is open you open with fail  then loop and try again until you can open it.  Once open just execute your macro.
    This can loop until you can open the file.
    Set xl = CreateObject("Excel.Application")
    Do While True
    Set wb = xl.WorkBooks.Open("C:\scripts\test.xlsx")
    If wb.ReadOnly Then
    MsgBox "readonly"
    wb.Close()
    Else
    MsgBox "OK"
    Exit Do
    End If
    WScript.Sleep 5000
    Loop
    xl.Quit
    ¯\_(ツ)_/¯

Maybe you are looking for

  • How to see data in a transaction ODS

    Hi all, I am populating data into my Transactional ODS through the function module RSDRI_ODSO_INSERT_RFC . But not able to see the data in it. as there is no manage option to the ODS. and by default an export datasource is created for the ODS. do i h

  • OO ABAP

    Hi all,       I am new to OO programing and  need your help in some aspects .I was going through this blog /people/thomas.jung3/blog/2005/10/26/alv-om-template-program <a href="/people/thomas.jung3/blog/2005/10/26/alv-om-template-program Thomas Jung<

  • Resolution of Logo

    Hi all, Can you suggest a way to change the resolution of Logo while importing it through SE78 transaction? Thanks and Regards, Deepthi Sankar

  • How does one get additional RAM?

    In trying to install Snow Leopard ( OSX) which is necessary to update Itunes for my new ipod, it says I don't have sufficient RAM. How does one get RAM? Or do I have to get a new computer?

  • Can I import my google & yahoo bookmarks to firefox

    I have a lot of bookmarks on both yahoo & google, and I would like to be able to access them from firefox. Can you please guide or show me how to go about this?