Search if a layersets with a specific name exist and execute a function if it is the case

Hello,
How can i write a script that search if a layersets with a specific name exist and execute a function if it is the case?
Some examples?
Many thanks.
Regards.
Sebastien

This would check for a LayerSet if a name with DOM code – so it’s fairly slow.
var check = checkForLayersetNamed(app.activeDocument, false, "thisName");
alert (check);
////// function collect all layers //////
function checkForLayersetNamed (theParent, theCheck, theName) {
/* if (!allLayers) {var allLayers = new Array}
  else {};*/
  for (var m = theParent.layers.length - 1; m >= 0;m--) {
  var theLayer = theParent.layers[m];
// apply the function to layersets;
  if (theLayer.typename == "ArtLayer") {
// allLayers.push(theLayer)
  else {
  if (theLayer.name == theName) {theCheck = true};
  theCheck = (checkForLayersetNamed(theLayer, theCheck, theName))
// allLayers.push(theLayer);
  return theCheck
Below is AM code Paul Riggott posted some time ago in connection with linking Layer Masks.
Re: Automatically re-link layer masks
You could add a check for whether the Layer is a LayerSet, but if the name is the sole distinguishing feature this might work as a basis for your operations.
app.bringToFront();
main();
function main(){
if(!documents.length) return;
linkLayers();
function linkLayers(){
   var ref = new ActionReference();
   ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
   var Names=[];
try{
    activeDocument.backgroundLayer;
var i = 0; }catch(e){ var i = 1; };
   for(i;i<count;i++){
       if(i == 0) continue;
        ref = new ActionReference();
        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
        var desc = executeActionGet(ref);
        var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
        var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
        if(layerName.match(/^<\/Layer group/) ) continue;
/* you could insert your operations in an if clause here */

Similar Messages

  • Test whether a layer with a specific name exists?

    Is there a simple way to test whether a layer with a specific name exists?

    Simon Dav wrote:
    - Multiple layer names
    - working only for one layer name
    - can you help me for this, how to get multiple names.
    - layers "Background", "Artwork", "diecut", "size", "sign of panel"
    This should work, as one possible approach:
    var doc = app.activeDocument
    var layersToTargetNameArray = ["Background", "Artwork", "diecut", "size", "sign of panel"];
    for (var i = 0, il = doc.layers.length; i < il; i++) {
        var curLayer = doc.layers[i];
        for (var j = 0, jl = layersToTargetNameArray.length; j < jl; j++) {
            if (curLayer.name == layersToTargetNameArray[j]) {
                // do something if layer name found
                curLayer.visible = false; // basic example
            } else {
                // do something else if layer name not found
    Hope it helps your efforts.
    Please Note: If your question exceeds this working response with further unrelated requirements (non related to this thread) you should start a new thread instead for your question, as proper etiquette.

  • Adding a sheet in excel with a specific name.

    How can I add a sheet in excel with a specific name after an existing sheet with an unknown name.

    Just use the Sheets->Add function and wire the existing sheet index into the After input.
    From the Workbook refnum:
    Wire Property Node - Workbook->Sheets
    Wire Method Node - Sheets->Add, wire the After input
    Convert the Variant from Add into a WorkSheet type
    Wire Property Node - WorkSheet Name
    Michael Munroe, ABCDEF
    Certified LabVIEW Developer, MCP
    Find and fix bad VI Properties with Property Inspector
    Attachments:
    Add_Sheet.gif ‏4 KB

  • HT4972 i have an iphone 4 with ios 5.1.1 and i want to upgrade it to the latest ios 6 and not 7 because its too heavy for iphone 4 how can i do it

    i have an iphone 4 with ios 5.1.1 and i want to upgrade it to the latest ios 6 and not 7 because its too heavy for iphone 4 how can i do it?

    You cannot. When you upgrade, you will get the latest version of iOS 7.

  • Frustration! I have all igoods in order to use all, fully as should be. But looks like Softbank does no agree with any connection between iPhone and iMac... What in the world! How Apple let that happen???

    I live in Japan,
    I have all igoods in order to use all, fully as should be. But looks like Softbank does no agree with any connection between iPhone and iMac... What in the world! How Apple let that happen??

    Make sure that you allow pages to choose their colors and that you haven't enabled High Contrast in the Accessibility settings.
    *Firefox > Preferences > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    See also:
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *https://support.mozilla.org/kb/Images+or+animations+do+not+show

  • Why do i constantly get cut off on calls.  I've had this problem with my 3GS, my 4S and now my iPhone 5.  When the core functionality is Phone, i.e. the ability to talk, why can't Apple make the iPhone function as a Phone?  is there an App for that !!

    why do i constantly get cut off on calls.  I've had this problem with my 3GS, my 4S and now my iPhone 5.  When the core functionality is Phone, i.e. the ability to talk, why can't Apple make the iPhone function as a Phone?  is there an App for that !!

    Well, since you've had the same problem, with three different phones, that all use different size sim cards, it seems pretty obvious the problem is with your carrier/coverage & nothing to do with your phone or sim card.

  • How to wipe off everything from my 15 MacBook Pro? I bought my Mac in Middle 2010. It was with OS X Snow Leopard, and a few months ago, I installed the Lion, so I couldn't just insert the CD and reinstall.

    How to wipe off everything from my 15 MacBook Pro? I bought my Mac in Middle 2010. It was with OS X Snow Leopard, and a few months ago, I installed the Lion, so I couldn't just insert the CD and reinstall.

    Yes, you can and should. The DVD belong with the MBP. You should use the original DVD to erase the disk and install Snow Leopard prior to sale.
    You can't sell it with Lion because it is authorized under your user ID.
    Allan

  • Imac won't shut down, blue screen with spinig wheel is on and computer never shuts until I hold the power button down and shut it manualy..

    Imac won't shut down,
    blue screen with spinig wheel is on and computer never shuts until I hold the power button down and shut it manualy..

    This is the instruction article for Intel-based Macs:
    http://support.apple.com/kb/HT3964
    Your profile does not indicate the type of Mac you are using.
    Barry

  • My ipod shuffle 4th gen bought today and the voice over works for naming playlist and battery percent but wont name song and artist can anyone help also is the voice over button meant to be soft when pushed ?

    my ipod shuffle 4th gen bought today and the voice over works for naming playlist and battery percent but wont name song and artist can anyone help also is the voice over button meant to be soft when pushed ?
    thanks

    This document explains setting up and using VoiceOver.
    http://support.apple.com/kb/ht4322
    The overall settings for VoiceOver is on the shuffle's Summary screen in iTunes.
    Artist name and song name - Press and release the VoiceOver button. 
    The playlist menu - Press and hold the VoiceOver button.

  • I need to be able to save pictures with a specific name and email as a .jpg file (not an jpeg image).  Any app suggestions to be able to do this?

    I purchased Photoshop Touch which let me save the picture with a name, but when I emailed it, is was an jpeg image. 
    Anyone know how I can do this or have suggestions for other apps.   I've done quite a bit of research and having trouble finding this specific type of information
    Thanks!!

    Hi, I had the same issue. My solution was to take the freeware-tool clickto.
    So I'm now able to take any text, copy it and past it via clickto into a new mail.
    [http://www.clicktoapp.com Clickto ]expands your copy-paste feature by showing you some "satellites" after doing the copy action. These "satellites" now will give you some opportunities to paste your copied content, for example a picture to facebook or a text to a new mail on gmail with just 1 single click.

  • When I type in web searches, Firefox remembers them with a system similar to predictive text. How can I erase the search history list, because deleting the history with the organise tool doesn't work. Please help.

    When I type in searches I don't want a box to appear under the search box trying to predict what I'm going to type next. Can I disable the system(prediction box) or erase the history list or both?

    Thanks for the suggestion, but no effect, when I right click on the search bar all I get is; select all (which does nothing), add keyword to this search (which is the opposite of what I want) and add dictionary (again adding something). Do you have any other ideas? :)

  • How to check if a specific file exist and which exit code to use ?

    Hi, First I'm not a scripting guy and I know almost nothing about VB scripting.
    I have a deployment of 6 tasks and I want to make sure that step # 2 will not be process if it failed in step #1, and so on for the 6 task.
    To do this, i have to run a vb script before installation or uninstalltion on each steps
    I'm trying to use a script (not from me) that i have modified for pre-uninstallation of software and also post-installation of the software.
    Pre-uninstallation: The script will look if the specified "exe" exist on the server and if so, than it will run the msiuninstall "application_name".
    If the uninstallation is successful, the post-installation script will check if the "exe" file exist again on the server, and it shouldn't find it (because it was deleted from the uninstallation), than it will return an exit code of successful
    to run the next process.
    Here an example:
    Step 1: Uninstall "Software#1" with msiuninstall Software#1.exe command
    Step 2: Uninstall "Software#2" with msiuninstall Software#2.exe command
    Step 3: Install "Software #3"with an .exe extension
    Step 4: Re install "Software #2" with an .msi extension
    Step 5: Re install "Software #1" with a .msi extension.
    Step 6: Send email to confirm the deployment is successful
    So i need to validate that step #2 will not process step #3 if it failled on # 2. It need to validate if the file exist before and after.
    At the end, Step 6 should send an email to confirm that the 6 steps of the deployment was completed without errors.
    Any idea how to do it ?
    Many many thanks for all the help !
    A desperate guy :)
    This is what i have
    'This script will look if an .exe file exist for a specific application.
    '=============================================================================================
    path = WScript.Arguments.Item(0)
    set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(C:\Inetpub\wwwroot\Enterprise\EnterpriseWS\web.config) = true then
        exitCode = 0
    else
        exitCode = 1
    End If
    Wscript.Quit exitCode

    Since you are not a scripting guy here is a very good place to start:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    ¯\_(ツ)_/¯

  • I have a new Windows tablet computer with limited hard drive space, and cannot transfer my itunes library to the hard drive. Can I run t media from an external hard drive? If so, how do I transfer my files?

    I have a new Windows tablet computer with limited hard drive space (32 GB), and cannot transfer my itunes library to the hard drive. Can I run itunes from an external hard drive? I have tried to follow some of the directions on this site, but am having no success. Thanks.

    iTunes will run fine with the media on an external drive.
    However, I suggest that a tablet computer with a tiny hard drive is not ideal as the primary computer for managing an iTunes library, even a small one. If you have another machine, perhaps a big, boxy, inexpensive old desktop with a decent amount of storage, that might be a better choice.
    http://support.apple.com/kb/HT1364

  • HT200233 Compressor 4.1 - I'm having trouble creating an MPEG 2 file w/dolby sound. Regardless of the duration settings I select, compressor spits out a 50 minute file with my 10 minute project and 40 minutes of black tacked on the end. Any suggestions?

    My original file is an Apple Pro Res 422 .mov with a 10:55 duration at 23.976fps. I don't have any issues converting this file to any other format - just to the MPEG 2. I'm not trying to alter the frame rate: I just want to compress to the two separate files: a Blu-Ray stream MPEG-2 with a bitrate of 30mbs and a Dolby Digital .ac3
    No matter what I try I always seem to get a roughly 50 minute file (although this duration varies by 4-6 minutes which is confusing) which contains my original video without any problems, and then is filled with a black screen for the remaining time.
    I've never had this issue with previous versions of Compressor - if anyone has any suggestions I'll gladly give them a try!
    Thanks

    My original file is an Apple Pro Res 422 .mov with a 10:55 duration at 23.976fps. I don't have any issues converting this file to any other format - just to the MPEG 2. I'm not trying to alter the frame rate: I just want to compress to the two separate files: a Blu-Ray stream MPEG-2 with a bitrate of 30mbs and a Dolby Digital .ac3
    No matter what I try I always seem to get a roughly 50 minute file (although this duration varies by 4-6 minutes which is confusing) which contains my original video without any problems, and then is filled with a black screen for the remaining time.
    I've never had this issue with previous versions of Compressor - if anyone has any suggestions I'll gladly give them a try!
    Thanks

  • How to search a user just with his login name ?

    I want to read some properties of a user n i have only the 'Login name' of that user(the Login name available with me is of the different user and not of the logged in user)
    Help me out :_|

    It sound like you want to do a basic user search?
    Here is how we do it in .NET for our custom user search portlet:
    private IPortletContext     portletContext;
    protected DataGrid dgResults;
    private DataTable resultsTable = null;
    protected System.Web.UI.WebControls.Label lblMessage;
    protected System.Web.UI.HtmlControls.HtmlTableCell resultsCell;
    private void Page_Load(object sender, System.EventArgs e)
    portletContext     = PortletContextFactory.CreatePortletContext(Request,Response);
    string searchString;
    searchString = Request.QueryString["TextName"];
    // build up a search request for the matching users
    IRemoteSession prcSession          = portletContext.GetRemotePortalSession();
    ISearchFactory searchFactory          = prcSession.GetSearchFactory();
    IPortalSearchRequest searchRequest     = searchFactory.CreatePortalSearchRequest();
    IUserManager userManager = prcSession.GetUserManager();
    ObjectClass[] objectTypes = {ObjectClass.User};
                   searchRequest.SetObjectTypesToSearch(objectTypes);
    if( !searchString.Equals("")){
    IFilterClause generalClause          = searchFactory.CreateAndFilterClause();
                        generalClause.AddStatement(PlumtreeField.NAME, Operator.Contains, searchString);
    Field[] fieldsToReturn = {
    (Field) PortalField.ForID(156), // 156 = Company
    (Field) PortalField.ForID(157), // 157 = Address
    (Field) PortalField.ForID(163), // 163 = Address2
    (Field) PortalField.ForID(162), // 162 = City
    (Field) PortalField.ForID(159), // 159 = State
    (Field) PortalField.ForID(158), // 158 = Zip Code
    (Field) PortalField.ForID(222), // 222 = Location
                        searchRequest.SetFieldsToReturn(fieldsToReturn);
                        searchRequest.SetQuery("*", generalClause);
    ISearchResponse searchResponse = searchRequest.Execute();
    ISearchResultSet resultSet = searchResponse.GetResultSet();
                        System.Collections.IEnumerator results = resultSet.GetResults();
    // build up our data table, we will bind this to the data grid once populated
    resultsTable = new DataTable("ResultsTable");
    System.Data.DataColumn key = new DataColumn("name", System.Type.GetType("System.String"));
                        resultsTable.Columns.Add(key);
                        resultsTable.Columns.Add("title", System.Type.GetType("System.String"));
                        resultsTable.Columns.Add("phonenumber", System.Type.GetType("System.String"));
                        resultsTable.Columns.Add("address", System.Type.GetType("System.String"));
    System.Data.DataColumn[] keycolumn = { key };
    resultsTable.PrimaryKey = keycolumn;
    while (results.MoveNext())
                             IPortalSearchResult result = (IPortalSearchResult) results.Current;
    //string viewProfileLink = "<pt:standard.openerlink pt:objectid='" + result.GetObjectID() + "' " +
                             //     "pt:classid='1' pt:mode='2' target='userProfileResult'>" + result.GetName() + "</pt:standard.openerlink>";
    string address = result.GetFieldAsString((Field) PortalField.ForID(157));
    string address2 = result.GetFieldAsString((Field) PortalField.ForID(163));
    string city = result.GetFieldAsString((Field) PortalField.ForID(162));
    string state = result.GetFieldAsString((Field) PortalField.ForID(159));
    string zip = result.GetFieldAsString((Field) PortalField.ForID(158));
    string location =result.GetFieldAsString((Field) PortalField.ForID(222));
    string fullAddress = "";
    //added in location
    if(location !="" &&location!=null) fullAddress+= location+"<br/>";
    if(address != "" && address != null) fullAddress += address + "<br/>";
    if(address2 != "" && address2 != null) fullAddress += address2 + "<br/>";
    fullAddress += city + " " + state + " " + zip;
    string name = "<a href='mailto:" result.GetFieldAsString((Field) PortalField.ForID(258))"'>"+result.GetName()+"</a>";
    // add all of the users to our results table
    object[] newUserRow = {     //result.GetName(), 
                                            name,
                                            result.GetFieldAsString((Field) PortalField.ForID(153)), // Title
                                            result.GetFieldAsString((Field) PortalField.ForID(152)), // Phone
                                            fullAddress,
                             resultsTable.Rows.Add(newUserRow);
    // bind the table to the grid
                        resultsTable.DefaultView.Sort = "name";
    dgResults.DataSource = resultsTable.DefaultView;
    dgResults.DataBind();
    if(resultsTable.Rows.Count < 1)
    dgResults.Visible = false;
    Label lblNoResults = new Label();
    lblNoResults.Text = "The current search '" + Request.QueryString["TextName"] + "' returned 0 results.";
                             resultsCell.Controls.Add(lblNoResults);
    resultsCell.Width = "100%";
    resultsCell.Align = "center";
                             resultsCell.Style.Add("padding-top","5px");
    Edited by geoffgarcia at 08/02/2007 12:59 PM

Maybe you are looking for

  • Parsing errors with CDATA tags using oracle xml parser v2

    I'm using the oracle.xml.parser.v2 parser to combine a generated xml document from a database with a static xsl file to produce html. Within the xml document, there are fairly large CDATA sections (500 lines) which happen to contain javaScript. Occas

  • Process Flow Deployment using Oracle workflow

    Hi, If I have my own Process Flow in XPDL, can I deploy it to the Oracle workflow? I couldn't find any doc regarding how Oracle workflow (standalone) imports XPDL file. Is the Oracle workflow packaged with the OWB comes with some adapter that underst

  • JDev 11g generates jaxrpc File instead of jaxws

    Hello *, I found some interesting behaviour but haven't digged deeper into that area. Whe I generate a jax-ws WebService with JDeveloper 11g, it generates me on the filesystem besides the PortType implementation a file called +"MyService.jaxrpc"+. To

  • Ora-01219 database not open

    Hi, i am getting ora-01219 error on standby database? what my be wrong?

  • When is the iphone 5 being released?

    When is it getting released in Australia?