Detecting a layer by name

The following code is part of a larger script. I'm trying to detect if the layer "Canons Grid" exists. If it doesn't then create a new layer with that name. This code fails everytime, even if the layer doesn't exist. What am i doing wrong?
var doc = app.activeDocument;
var canonLayer;     
      try {
                  canonLayer = doc.layers.itemByName("Canons Grid");
            catch(e)
                  canonLayer = doc.layers.add({name: "Canons Grid"});

canonLayer = doc.layers.itemByName("Canons Grid");
always succeeds, as your own code demonstrates:
var canonLayer = doc.layers.item("Canons");
if (canonLayer.isValid == false) {
Therefore in tusharde's original code, the catch() never executes.
Peter

Similar Messages

  • Photoshop CS5 Hangs on Layer Group name edits

    Layer Group name edits are causing my PS CS5 to hang repeatedly. At first I thought it was the document I was working in, so I created a generic document, and was able to replicate the problem in the new document.
    With a .psd open, in the layers pallete, I have a Layer Group (A) that contains multiple sub layer groups (B) which contain additional sub layer groups (C). So the hierarchy is a three level layer group. At the sub-most layer group (C) I need to rename the groups to "Three-set colors". Since I have fifteen groups that all need the word "Three" in their labels, it would be most convenient to be able to highlight the word "Three", copy to clipboard and paste. I type in the word "Three" in the layer group name (not in the properties insector) and highlight the word "Three". Thats when PS CS5 hangs, and I have to reboot my system to unfreeze Photoshop. Only Photoshop hangs, the system does not crash. This happens in both 64 and 32 bit, old or new docs.
    The plugins I have are Mask Pro x64 (OnOne) and Sitegrinder x32 (Medialab), but they are not activated when the hang occurs.
    Any ideas?
    PS CS5 12.01 x64
    Win 7 Ultimate
    12 gb ram
    i7 960 @ 320
    ATI Radeon HD 5700
    4x HD's

    I wasn't able to reproduce the problem with either Photoshop CS5 32 bit or x64.  That says there's something different about our systems, and that there's likely not a systemic problem in Photoshop.
    Chris Cox, who replied above, is an Adobe Engineer, by the way.
    I was able to replace parts or all of the names with, or insert the word Three in front of existing layer names.
    Are you seeing any errors in your Windows system logs at the time the hang is occurring?
    Have you updated all your software (e.g., video drivers, Windows Updates, etc.)?
    -Noel

  • Select layer by name.

    I need to be able to select a specific layer by name to make active. I cannot find any documentation.
    The layer name is always "PDF (Replace Contents...)" - then I'll replace the content with a specified  PDF (constant - naming convention also).
    -kp

    Search on getbyname in the scripting guides you will find documentation like this
    The collections, as in this example, can be treated as arrays, which is useful for iteration. They also provide
    methods to create their contained objects, and to access them by name:
    var newLayer = activeDocument.artLayers.add(); // Create a new ArtLayer object
    newLayer.name = "My Layer"; // name it for later reference
    var layerRef = activeDocument.artLayers.getByName("My Layer");
    so you would code somethinf like this
    try { var layerRef = activeDocument.artLayers.getByName("PDF");}
    catch(e){
                        alert("Document does not have the Required PDF layer");
                        var abort = true

  • Run action to find layer by name and select it...

    I have a folder of 10,000+ files that I need to run a simple action on. I'd like to open a file, have it find the topmost layer names "RED," select it, rasterize it, and then save/close. I've been able to figure out every step except selecting the layer I need. I've tried the "insert menu item" command in the actions drop down menu, but it only gives me options for things like "select all layers" or "select similar layers." The "Insert select path" only lets me select 10 paths at a time, and won't select compound paths. What I need is to be able to select a layer named "RED" as part of the action. Photoshop allows you to do that, so I was hoping Illustrator might afford me the same convenience. Any ideas?
    Vinny

    The following is an AppleScript. Open the ScriptEditor in the applescript folder and paste into a new window. Run it on a sample folder and we'll see how it does.
    --get a sourceFolder that holds the files to print
    set sourceFolder to (choose folder with prompt "Choose a folder with files to process:") as text
    -- get a list of files of the files to be printed in the sourceFolder
    tell application "Finder" to set workingFiles to (every file of folder sourceFolder) as alias list
    repeat with workingFile in workingFiles
        tell application "Adobe Illustrator"
            open workingFile
            tell current document
                set layerRef to (first layer whose name is "RED")
                set g to every page item of layerRef
                repeat with i from 1 to count of g
                    set selected of item i of g to true
                    do script "raster" from "Default Actions" without dialogs
                    delay 1
                end repeat
            end tell
            close current document with saving
        end tell
    end repeat
    Don't include the underlines.
    The do script line refers to an action you create in your default actions with just one thing. It's case sensitive.
    Let me know if you need more help

  • How to detect USB Flash Drive name in LabVIEW

    Hi there
    I was looking for how to detect a USB Flash Drive name in Labview
    appearently every time i insert USB Flash Drive in a computer, windows assign it a different name
    once "J:" and sometimes "M:"
    Is there anyway to obtain USB Flash Drive name programmatically in Labview ?
    Because in my program an user shouldn't be able to access HDD Drives except his USB Flash Drive (for inserting some file ...)
    thank you and excuse me for my poor english 

    I was able to get the demo.vi to load, but it could not load the other two because there is no block diagram associated with those.  I'm not sure why this is.  I haven't had any issues with other llbs before.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Linking photo layer and name layer

    I am producing a large number of memorymates and would like to link the individual photo layer with the corresponding name layer to simplify printing.  Is this practical in cs4?

    I would also look at Layer Sets, where the student's image Layer and their Text Layer would be grouped and linked, and their name can be used in the Layer Set too.
    This is rather like a DVD/BD Menu, where each Button is a Layer Set, and all Assets for that Button, graphics, Text, Shapes, Sub-picture Highlight Layer, etc., will be grouped inside that Layer Set. The Layer Sets are automatically named Button 1, Button 2, etc., but one can easily change those to say, Scene 01, etc.
    Good luck, and hope that gets you what you want and need.
    Hunt
    PS you can even assign separate colors to the Layer Set icons, to help you identify them, if you wish. Say yellow for the top row of students, green for the next, and so on.

  • How to detect the installed device name

    Hi,
    I am using Labview 8.5.
    I need to display the device name installed in my pc.
    I have a PXI chassis with DAQ,Digitizer and function generator card.To display the DAQ device name used the "DevName" property of DAQmx driver.Similarly to display the Digitizer and function generator card name which function do we need to use.
    Please tell me how to do this?
    Regards
    Meenatchi

    Please see the attached zip of VIs.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Detect Installed Device Details.zip ‏131 KB

  • Presentation Layer column name change effects on existing reports ?

    Hello Gurus,
    I have one requirement where user are not sure about the column names in Presentation Layer.
    so they want us to create the reports and once the reports are delivered they will give us the column name as per their requirement.
    now i read couple of blogs related to this, that does it affects the exiting reports?
    in couple of blogs they says that i won't. becaus BI server creates the alias for the old name and will reflects it wherever it's used in reports..
    So can anyone tell me where this alias name has been stored in OBIEE?
    and is there any precaution that needs to be done while doing this beacuse we are expecting to create around 40-50 reports and changing the column name after changing the presentation layer name change will increase lots of work..
    Thanking You..

    I've confirmed it on a 10g environment that when you rename the column in the RPD the existing reports reflect the change.
    What I was referring to in the statement you highlight is that a column name can be changed when being used as the definition of a report. If somebody specifies an abbreviation of the current name to fit it in a table or chart then it will not be updated from a name change in the RPD.
    So long as you build reports using the name provided by the RPD and none of the developers take the liberty of renaming it in the column properties of the request/analyses the single rename should take effect through all the reports you build.
    You can also manage the column name by renaming it in a report and using the save as system wide default. But the way you intend to do it would be the best method.
    Edited by: James - Projected on 25-May-2012 14:07

  • Select a layer whose name is the same as another layer

    I have two layers with the same name. How can I select the one I want from an automation plugin?
    thanks
    Bill

    I wonder if this may help.
    The top left of the bounding box will be the layer bounds [0] (left) and [1] (top)
    #target photoshop
    app.documents.add();
    var FontName = "Arial";
    var FontSize = 14;
    var black = new SolidColor();
    black.rgb.hexValue = '000000';
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    var newTextLayer = activeDocument.artLayers.add();
    newTextLayer.kind = LayerKind.TEXT;
    newTextLayer.textItem.kind = TextType.POINTTEXT
    newTextLayer.textItem.color = black;
    newTextLayer.textItem.font = FontName;
    newTextLayer.textItem.size = FontSize;
    newTextLayer.textItem.contents = "The quick brown fox jumps over the lazy dogs back 1234567890";
    newTextLayer.textItem.kind = TextType.PARAGRAPHTEXT;
    newTextLayer.textItem.height =300;
    newTextLayer.textItem.width = 100;
    newTextLayer.textItem.position = Array(10, 10);
    newTextLayer.textItem.justification=Justification.CENTERJUSTIFIED;
    var LB = newTextLayer.bounds;
    var doc = activeDocument;
    alert("Bnds height = " + (LB[3]-LB[1]) + " Bnds Width = " + (LB[2]-LB[0]));
    alert("BB Height = " + doc.activeLayer.textItem.height + " BB Width = " + doc.activeLayer.textItem.width);
    app.preferences.rulerUnits = startRulerUnits;

  • Detecting if layer is a duplicate of another layer

    Is there a way to say if a given layer is a duplicate of another?

    If you are trying to find a rogue duplicate layer that is lurking in a project, you would need to scan all the layer properties of your source layer. Then compare those against the same properties on every other layer in the project. A very time intensive process, unless you have some common key values to search for first, like frame size, duration or name. You could narrow down the overall pot of content to compare first if you did that.

  • Detect Browser Version & Browser Name

    Hello,
    I have written some java code to detect browser version & name but its not working in ADF. Please help to detect browser details.
    public void browserDetail(HttpServletRequest request,
    HttpServletResponse response)throws IOException,ServletException{
    response.setContentType("text/html");
    Enumeration headerNames = request.getHeaderNames();
    while(headerNames.hasMoreElements()) {
    String headerName = (String)headerNames.nextElement();
    System.out.println("BrowserName" + headerName);
    System.out.println("Header" + request.getHeader(headerName));
    Please Help
    Thanks

    Hi,
    try this: http://blogs.oracle.com/jdevotnharvest/entry/how_to_detect_browser_type
    Frank

  • Ical or Calendar (or whatever) doesn't detect dates and calendar names anymore!

    Hi everyone.
    I used to have a weekly email created with automator and ICal, parsing a specific calendar by its name, and creating
    a list of events occurred in the week (monday to sunday) to send. I used an automator ical alarm for this (now called automator CALENDAR alarm???).
    It worked like a charm.
    Enter Mavericks.
    It's doesn't work anymore.
    Couldn't open the file. So I set to edit it and re-create it, but to no avail.
    I've tried to debug it, by going down to basic actions and their output, and I found out that for example:
    - A one action workflow, find calendar events, with date starting this week, doesn't work!
         No output, when I have pretty many events occurring in the week.
         It doesn't work even if I change the condition (today, or 2 days from now etc...)
    - Another single action workflow (still for testing purposes), filter calendar where title contains any calendar name returns nothing, while there are many calendars in the app!
    Can anyone help?
    Did you experience the same problems?

    Any solution on this problem? I'm experiencing the exact same problem on our 2 GHz iMac Core 2 Duo.

  • How to detect remote (client) host name or remote host address?

    Hello!
    I need to receive remote host name or remote IP address in the BSP controller DO_REQUEST method. How to do it?
    In Java I can use getRemoteAddr() or getRemoteHost() methods of HttpServletRequest class. But in the BSP I can not find analogues of these methods.
    Please help
    Best regards,
    Eugeny

    Hi,
    I guess there is something "cleaner", but here is a solution:
    DATA l_host TYPE string.
    l_host = me->request->if_http_entity~get_header_field( '~remote_addr' ).
    Regards,
    Tanguy

  • Detecting user and domain name

    I am developing an application that will have an autologin option based on OS current logged user.
    How do I determine what the domain name is in Windows?
    Thanks

    This link has the native windows code to retreive domain name:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;111544
    Use JNI.

  • How to create an action to save the file as the name of the selected layer

    I have a .psd with several layers, and I would like to save multiple versions of the document based on the layer name. Is there a way to tell Photoshop to do this through an action? Also, how can I get rid of the "filename_copy" filenaming behavior. I'd like to hit a button and have the file saved as the layer's name while overwriting the existing document without renaming it to whatever_copy.

    The bad news is that it's not possible with an action.  An action simply can't access a layer name.
    But the good news is that it's possible with a script.  Almost anything's possible with a script.
    But the bad news is I'm no script expert.
    But the good news is that there are script experts who hang out here.
    The even better news is that there's a Photoshop scripting forum.
    Best of luck! 
    -Noel

Maybe you are looking for

  • How to create an automatic email when a new announcement is created

    Hi, In Sharepoint 2013, how can I configure it to automatically send an email to all users when a new announcement is created? Regards, Stephen.

  • In WebDynpro ,How to add the print function in a view ?

    Hello! everyone, I have one task in protal, There are 2 views in my webdynpro project, the 1st view are list name items.  when I click the name link will open the 2nd view , the 2nd view is a detail view page for each name,  now , I want print the 2n

  • Multi user application control data access

    Dear all, i am using Oracle Developer Suite 10g and database 10g, windows xp plate form. i want to develop multi user application regarding education. i have two questions. 1. i take a start from creating an HR database which have 30 tables. this dat

  • Can't "get" entire site

    Hello, I'm trying to get my entire site using DW 5.5 so that I can work on it locally, but lots of the file are being left behind. I follow the instructions to do so, click yes when prompted if I want to get the entire site and the process begins. It

  • FAQ: How do I build a simple email form in Flash Catalyst?

    You can transfer projects into Flash Builder to add functionality like this. Be aware that with Flash Catalyst CS5 and Flash Builder 4, this is a one-way trip. Here is a tutorial by Tanya Heins that explains how: Creating a simple form with Flash Cat