Turn on layer visibility without exact name

Hi all,
This is my first post, and my first attempt to edit javascript for AI, so please bear with me! 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?
Thanks in advance for any help!

Looking at the way you have set your files up you don't need to know any names while it is possible to do that I think you are just making more work for yourself… All you actually need do is get a ON/OFF list from each layer name as this is ordered…
Edit OK I had a quick go to see if this worked… this appears to what I think you are wanting…
#target illustrator
exportLayerSets();
function exportLayerSets() {
          var doc, lay, visList, i, j;
          doc = app.activeDocument;
          for ( i = 0; i < doc.layers.length; i++ ) {
                    lay = doc.layers[i];
                    lay.visible = true;
                    visList = lay.name.match( /ON|OFF/gi );
                    if ( visList != null ) {
                              for ( j = 0; j < visList.length; j++ ) {
                                        if ( visList[j] == 'ON' ) {
                                                  doc.layers[ i + j + 1 ].visible = true;
                                        } else {
                                                  doc.layers[ i + j + 1 ].visible = false;
                    app.redraw();
                    alert( 'Is this working?' );
                    // EXPORT HERE…
                    lay.visible = false;

Similar Messages

  • Using hyperlink to toggle layer visibility?

    Okay, I've got a few threads going in other forums on this, and I'm getting a little frustrated with retyping it all, so I'm going to try to be brief... if you have any questions on what I'm trying to do, sorry for being vague, just ask and I'll try to clarify (I know, I hate posts that don't give enough info to work from).
    OKay... I work with surveillance systems, and for one customer, I'm taking existing PDFs they have of site floorplans, loading them into Ilustrator CS5, adding icons and text showing camera locations and fields-of-view, then exporting to PDF, loading that into Acrobat Pro X, and adding a hyperlink to each camera icon that when clicked, will open a window with a still capture from that camera, so they can see what the view is "supposed" to look like.
    This works fairly well, and the client is happy with it... there's just one annoyance: every click produces a dialog box warning about opening an external program, and in newer versions of Reader, there's no "Don't display this again" checkbox.  A way around this would be great, but I had a better idea:
    I'm already creating layers in Illustrator: one for the floor plan, a second for the camera icons, a third for the text, and a fourth blank one so I can "swap out" the underlying floor/camera info without losing the hyperlinks (anywhere from 16 to 30, depending on the site).
    I had the idea that what I could do, is add a separate layer for each camera's sample image, which would allow me to add the image directly to the document, and have it just appear over the floor plan, rather than loading in a separate app.  Then I could have the image layers start out invisible, and toggle the visibility by clicking the camera icon.
    So I found this article that describes changing layer visibility from a hyperlink: http://help.adobe.com/en_US/Acrobat/9.0/Professional/WS58a04a822e3e50102bd615109794195ff-7 c5b.w.html
    It... sort of works.  I can create a link that will show a hidden layer... but not re-hide it.  I created a separate link that would hide it... but not show it.  Not really suitable - I'd like to have the same link toggle the layer on/off (heck, it would pretty much have to, or you KNOW the end users will get confused). 
    And the whole process seems a little clunky, at least from the above instructions.  Is there a better way to do this in Acrobat X?  Maybe a way to do it all within Illustrator?  Hope I'm clear enough about what I'm trying to achieve.
    If all else fails, is there a way to get rid of the $&^@*#!!! external program warning popup??
    Thanks, all!

    Forget that help page example, it's only practicable if you're setting a very simple pattern of layers.
    Instead, you should look at the JavaScript commands to control the visibility of individual layers, referencing them by their stacking order or name.
    For example this snippet will turn on the layer called "camera1":
    var ocgArray = this.getOCGs();
    for (var i=0; i < ocgArray.length; i++) {
      if (ocgArray[i].name=="camera1") ocgArray[i].state = true;
    You can easily extend this idea by creating a document-level function in the PDF, and calling that function from your links. For example if all your camera layers are named "camera1","camera2", etc. and you have a doc-level function like this:
    function showCamLayer(theName) {
      var ocgArray = this.getOCGs();
      for (var i=0; i < ocgArray.length; i++) {
        if (ocgArray[i].name.substr(0,6) == "camera") ocgArray[i].state = false;
        if (ocgArray[i].name == theName) ocgArray[i].state = true;
    then you can set your links to "run a JavaScript" and enter a single-line command such as showCamLayer("camera4")

  • Save Layer Visibility Settings

    So, I have an Illustrator CS5 file with 30 different layers of artwork that I've been using to create PDF city maps.  Is there a way that I can save layer visibility settings for each map? i.e. For one map, I want these 8 layers to be visible, for another, I want 6 other layers to be visible (and so on).
    I'm also using sublayers but I'm just wondering if there's a script or something that will remember certain layer visibility settings. Artboards?
    Thanks

    You might try using View>New View. It will entail going through and setting each map as you would like by turning on and off the layers you want and then save that view with a distinctive name. Then you can use the saved views to act as Layer Comps.

  • Save layer visibility states into new PDF

    Hi there,
    I have a document that is a floorplan of a building. I have created color layers to highlight specific rooms (e.g. Office 1, Office 2, Women's/Men's room, Storage room, etc.). I would like to save the PDF (overwrite or as a new PDF) with certain layers turned on so that the next time it is opened (by me or a client), the highlighted rooms are still showing. I found a somewhat convoluted way of doing this in Acrobat using Bookmarks and tying a "Set layer visibility" Action to it, but I am not sure how to go about doing it in Reader. Or should I look into creating a button or JavaScript in Acrobat so that it can complete the same tasks in Reader?
    Thank you for your help,
    Serge

    You might try using View>New View. It will entail going through and setting each map as you would like by turning on and off the layers you want and then save that view with a distinctive name. Then you can use the saved views to act as Layer Comps.

  • Need to know the exact name and P/N of a spare part, cannot find it anywhere.

    Hello,
    I would like to know the exact name and P/N of the -Touch Panel Control Assembly- for the HP Pavilion dv3510nr?.  
    or is it -Touch Panel Kit-?
    or is it -Multimedia Touch Control Panel-?
    Recently, mine got physically damaged and none of the touch buttons work, I cannot even turn the WiFi on. So I need to replace it, but I cannot find this spare part anywhere.
    It does not appear on the list of spare parts for this laptop, with any of those names.
    Does anybody know where can I find this spare part?
    Thanks very much.
    Glendy

    In case it was not very clear, the spare part that I am referring to is the panel placed above the keyboard, that has touch sensitive buttons for multimedia functions and for enabling the wireless device.
    Buttons appear In this order:
    MediaSmart button
    Audio on/off button
    Volume control
    Skip backward button
    Play/Pause button
    Skip forward button
    Stop button
    WiFi enable/disable
    Glendy 

  • Newbie q: rollover using layer visibility?

    Forgive the newbie question, I'm new to Fireworks (having used instead Photoshop and Golive since Golive 1.0).
    I have a layered Photoshop document I've brought into Fireworks (and the various layers have been organised into layer groups). I have series of bitmap graphic objects that I want the user to point at, and click on. What I want is to have a different bitmap graphic show when the user rolls over it (the graphics are gray text: point at a word and it turns white)
    The page, as it stands, has a single base layer where the bitmap items are gray and then, on top of this base layer, an individual layer for each graphic, but white this time (in register, of course, over their non-rolled over counterparts in the base layer). I've drawn slices over each text item, and I was hoping that I could use states (a new concept for me), along with layer visibility, to have a nice rollover behaviour.
    I had thought I could make a new state, then turn on visibility of a layer, and use that new state as the basis of a Swap Image rollover behaviour (or, when that didn't work, a Simple rollover behaviour). I'm not having any success, any layer that I make visible in one state, then becomes visible in the other state.
    The way I used to do this was to export two graphics from Photoshop for a rollover (one for mouseout, one for mousein), and to build the rollover behaviour that way. I'm pretty sure that Fireworks will do this too, but I'm really hoping that it's become more efficient than that, as I was building rollovers this way quite a long time ago! (anyone remember the Apple Media Tool?).
    I've read quite a bit about States, Layers and Pages in several tutorial websites (Adobe and others), and I'm afraid that I'm still not straight on how to achieve what I'm looking for. Can anyone help me out?
    Cheers!
    Chas

    That's great!
    Been using photoshop for a while and never noticed that Fill... menu item!
    Brilliantly simple and simply brilliant. There's a few actions I'll need to amend now.
    Thanks you so much for the speedy response

  • Toggle layer visibility

    Hello,
    I need one keyboard shortcut that toggles visibility of one of layers.
    I paint and need to toggle on and off one layer below (layer with a reference picture, not one i paint on). with a shortcut painting process will be not break as with case click at icon.
    tried to make toggle layer visibility with actions unfortunately with no success.
    it is possibility to toggle active layer visibility by add shortcut in keyboard shortcuts preferences  but here it going not about active layer.
    I have no experience with scripting.
    thank you!

    For this to work as written there can only be one layer in the document named 'Ref' otherwise it will toggle the top most layer with that name.
    var targetID = getLayerIDByName('Ref');
    if(undefined != targetID){
        if(getLayerVisibilityByID( targetID ) ){
            hideByName('Ref');
        }else{
            showByName('Ref');
    function getLayerIDByName(name) {
        try{
        var ref = new ActionReference();
        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));
        ref.putName( charIDToTypeID( "Lyr " ), name );
        return executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));
        }catch(e){}
    function getLayerVisibilityByID( id ) {
        var ref = new ActionReference();
        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Vsbl" ));
        ref.putIdentifier( charIDToTypeID( "Lyr " ), id );
        return executeActionGet(ref).getBoolean(charIDToTypeID( "Vsbl" ));
    function hideByName(name) {
        var desc = new ActionDescriptor();
            var list = new ActionList();
                var ref = new ActionReference();
                ref.putName( charIDToTypeID('Lyr '), name );
            list.putReference( ref );
        desc.putList( charIDToTypeID('null'), list );
        executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );
    function showByName(name) {
        var desc = new ActionDescriptor();
            var list = new ActionList();
                var ref = new ActionReference();
                ref.putName( charIDToTypeID('Lyr '), name );
            list.putReference( ref );
        desc.putList( charIDToTypeID('null'), list );
        executeAction( charIDToTypeID('Shw '), desc, DialogModes.NO );

  • Layer Visibility Overrides

    I'm having an issue with InDesign's Layer Visibility Options when importing a PSD file. I use the layer visibility option upon import of the PSD and shut off the layers I do not want showing. But then if I edit the PSD and add an additional layer, the file updates in InDesign and turns on every single layer again. Is there a way around this? It makes the layer options kind of useless to me.

    When I import the PSD into InDesign CS3, I make sure it says to preserve the layer overrides, but if I end up adding a new layer to the PSD, when it updates in InDesign the layer override goes haywire and shows all the layers.

  • Saving layer visibility as views does not work - CS5 for Windows

    I've read about it multiple places, even watched a video where it supposedly works. But when I toggle layer visibility and save as a new view, it doesn't seem to work.
    Here's the video: http://layersmagazine.com/illustrator-different-views.html
    Any ideas?

    Layer Visibility Variables – A short introduction
    1. Open a new document and name Layer 1 "Cyan"
    2. Add three main layers and name them "Magenta", "Yellow" and "Black"
    3. On each layer draw a shape and colour it according to the Layer's name.
    4. Save the file as "My_first_Variables.ai"
    5. Target Layer "Cyan" (click the circle at the right hand of the Layer's name)
    6. At the bottom of the Variables Palette click the Make Visibility Dynamic button
    Now you've created your first Layers Visibility Variable. Continue with
    7. Target Layer "Magenta" and click the Make Visibility Dynamic button in the Variables Palette
    8. Target Layer "Yellow" and click the Make Visibility Dynamic button in the Variables Palette
    9. Target Layer "Black" and click the Make Visibility Dynamic button in the Variables Palette
    Done. You have created four Layers Visibility Variables. The next step is to define the Data Sets:
    1. Layers Palette: Show Layer "Cyan" and hide all other layers
    2. Variables Palette: Click the Capture Data Set button (the camera icon)
    3. Layers Palette: Show Layer "Magenta" and hide all other layers. Now in the Variables Palette the first Data Set becomes italic indicating that you can create an new Data Set. So click the Capture Data Set button to define Data Set 2.
    4. Layers Palette: Show Layer "Yellow" and hide all other layers
    5. Variables Palette: Click the Capture Data Set button to create Data Set 3
    6. Show Layer "Black" and hide all other layers. Click the Capture Data Set button to create Data Set 4
    7. Show all layers and click the Capture Data Set button to create Data Set 5
    Done. You have created five Data Sets. Just play around by toggling them in the Variables Palette (Next/Previous Data Set button or via Popup menu/Flyout menu) and see one feature among other things: The Variables Palette as a remote control of the Layers Palette. If you like, rename the Data Sets according to the Layers names for instance.
    Now it's time to create some simple Save/Export actions in order to Batch save/export Layers as single files. For example:
    Export as PSD
    1. Open any file
    2. Actions Palette: Create new action and name it "Export Layers as PSD"
    3. File > Export as PSD. Choose any destination folder, the desired options in the Photoshop Options dialog and hit Enter
    4. Click the Stop Recording button in the Actions Palette and disable the Show dialog icon (on the left hand of the action's name)
    Save as PDF
    1. Open any file
    2. Actions Palette: Create new action and name it "Save Layers as PDF"
    3. File > Save as PDF. Choose any destination folder, the desired options in the PDF Options dialog and hit Enter
    4. Click the Stop Recording button in the Actions Palette and disable the Show dialog icon (on the left hand of the action's name)
    Now start the Batch command:
    1. Switch to the original "My_first_Variables.ai"
    2. Actions Palette Flyout menu: Batch
    3. In the Play Area choose the Export Layers as PSD action
    4. Choose Data Sets as the source
    5. In the Destination Area enable the Override Action Export Commands option and choose any destination folder
    6. Choose an option for the File name and hit Enter to start the Batch
    Done. All four Layers plus the fifth Data Set have been exported as single Photoshop files. Repeat the Batch with the Save Layers as PDF action (don't forget to enable the Override Action Save Commands) and, of course, create your own actions, experiment with other file formats, figure out some harmless bugs especially in conjunction with the PDF compatible AI format when placing in InDesign.

  • I want to write record type variable in ult file.How to i can write record type varable without column name.

    I want to write record type variable in ult file.How to i can write record type varable without column name.
    type rec_format_type is record
         format1  VARCHAR(3),
         format2  VARCHAR(3),
    my_record     rec_format_type;
    UTL_FILE.PUT_LINE(file_out, my_record);

    ibney wrote:
    I have below requirement.
    DECLARE
         emp_data UTL_FILE.FILE_TYPE;
    BEGIN
        emp_data := UTL_FILE.FOPEN ('EXDATAPUMP','TEST_BC_NN_PARALLEL.csv','W',32000);
        FOR TEST1 IN (SELECT /*+ PARALLEL(TEST_BC_NN,4) */  * FROM TEST_BC_NN) LOOP
            UTL_FILE.PUT_LINE (emp_data, TEST1);---Here i want to write record in utl file.without knowing the structure of table
        END LOOP;
        UTL_FILE.FCLOSE (emp_data);
    END;
    Why all the ugly upper case? You do realise that NO programming standard, ranging from Java and .Net, to C/C++ and Ada (of which PL/SQL is an implementation of), use upper-case-for-reserved-words as a standard.
    The easiest and simplest way to address your requirement is as follows:
    SQL> create or replace type TStringArray is table of varchar2(4000);
      2  /
    Type created.
    SQL>
    SQL>
    SQL> begin
      2          for c in(
      3                  select
      4                          TStringArray(
      5                                  to_char(empno,'000000'),
      6                                  ename,
      7                                  to_char(hiredate,'yyyy-mm-dd')
      8                          ) as COLS
      9                  from    emp
    10                  order by empno
    11          ) loop
    12                  for i in 1..c.Cols.Count loop
    13                          dbms_output.put( c.Cols(i) );   -- write column
    14                          if i < c.Cols.Count then
    15                                  dbms_output.put( '|' ); -- write column separator
    16                          end if;
    17                  end loop;
    18                  dbms_output.put_line( ' *end*' );               -- write record terminator
    19          end loop;
    20  end;
    21  /
    007369|SMITH|1980-12-17 *end*
    007499|ALLEN|1981-02-20 *end*
    007521|WARD|1981-02-22 *end*
    007566|JONES|1981-04-02 *end*
    007654|MARTIN|1981-09-28 *end*
    007698|BLAKE|1981-05-01 *end*
    007782|CLARK|1981-06-09 *end*
    007788|SCOTT|1987-04-19 *end*
    007839|KING|1981-11-17 *end*
    007844|TURNER|1981-09-08 *end*
    007876|ADAMS|1987-05-23 *end*
    007900|JAMES|1981-12-03 *end*
    007902|FORD|1981-12-03 *end*
    007934|MILLER|1982-01-23 *end*
    PL/SQL procedure successfully completed.
    SQL>

  • 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.

  • Layer Visibility Override icon

    My maps team have just seen this icon and are wondering why it's appeared in the links icon.
    I looked in the help section to find out but couldn't find much about it, does anyone have a second to explain to me regarding this icon, or how to turn it on or off?
    hope to hear from you
    Brgds
    Alex

    Help > InDesign Help
    Search for
    layer PSD
    Look for topic
    To set layer visibility for placed PSD or PDF files
    That should help.
    The icon beside the link it telling you someone has adjusted the visibility of its layers by using the Object Layer Options dialog box.
    HTH
    -mt

  • What is the exact name of the cable I need to connect my old hard drive from my macbook pro (it has been taken out of the computer) to my new macbook pro?  I need to transfer files from the old hard drive to the new computer.

    What is the exact name of the cable I need to connect my old hard drive from my macbook pro, which has been removed from the computer, to my new macbook pro?  I need to transfere files from the old hard drive to the new computer.

    No eSATA to USB. Just a SATA/IDE to USB adapter. Google SATA/IDE to USB adapter and you will get tons of links to buy them. Most likely your local computer electronics store has them, although they might be more expensive buying locally than online.
    I have several. You can get either USB 2, which what I recommend, or USB 3. USB is backward compatible so a USB 3 adapter will work on a USB 2 port and a USB 2 adapter will work on a USB 3 port. Backward compatible in both directions.
    I suggest a USB 2 type because there have been some problems with certain USB 3 devices, the USB 3 interface used isn't all that good in those certain devices. USB 3 is still fairly new where as USB 2 has been around for over 10 years.
    synghem wrote:
    Thank you LowLuster,
    At the apple store they said I needed an esata to usb wire.  But looking at wires on line has been confusing.  Is sata the same as esata?  How do I know if I need a usb 3 or usb 2?

  • How to Use 'uid' for AD Users Without Domain Name For User Log in OAM

    How to Use 'uid' for synchronized Active Directory (AD) Users into Oracle Internet Directory (OID) Without Domain Name For User Logins in OIDDAS and OAM
    We successfully integrated OAM 11g with EBS R12.1.3 Now all the AD user id's stored in fnd_users table as [email protected]
    How can we remove @abc.com
    We are using OID 11g and OAM 11g
    Found the similar note for OID 10G: How to Use 'uid' for AD Users Without Domain Name For User Logins in OIDDAS and SSO [ID 580480.1]
    We are in OID 11g.
    Any help on this greatly appreciated.

    I couldn't find any reference that could be helpful -- Please log a SR and see if this is supported and if the steps are available.
    Thanks,
    Hussein

  • I started downloading my Upgrade to Photoshop Elements Version 13 and received my upgrade confirmation and cannot locate the download on my PC running Windows 7,what is the exact name of the download and where should I find it?

    I cannot locate the upgrade to Photoshop Elements 11 to Version 13, which I purchased today and started the download as per the Order Confirmation. My order No. is AD014117711. I am running Windows 7 on my PC and cannot locate the Download. How do I find it? What is the exact name of the Download?

    EdWeidman by default the download will be saved to your Download folder.  I do not know the exact name of the file which was provided to you.

Maybe you are looking for