Sequentially number layer sets

Great, apparently if I add Tags it wipes out my question and just posts the tags as the message body. Brilliant. Re-typing...
I have a large and growing PSD with many layer sets (folders of layers.) I need to sequentially number the layer sets, but preserve their existing names. For example, layer set named "foo" should be renamed "001 foo",  the next layer set "bar" should be renamed "002 bar" and so on.
Doing this manually would take a long time, but more importantly, as I add new layer sets and reorder them I don't want to have to do it all over again.
I am not a programmer so I don't know where to begin writing this script. Google helped me find a few scripts that do something similar, but not exactly what I want. Most of the scripts I found will rename layers, but I need to rename the layer sets (folders.)
If it helps, I'll explain what I'm ultimately trying to do. I want to export each of my layer sets to an image, and have those images numbered sequentially based on the order of the layer sets. I already found a script that will export all of my layer sets to JPG images, so if I can find the script described above, I should be able to do this in two steps (1. rename layer sets, 2. export images.) If there is an easier or better approach, let me know.
I have Photoshop CS5 on Mac OSX Lion.
Any help is appreciated! Thanks!

Could you try this?
// add sequential three places number to beginning of layersets’ names or change existing three places number;
// 2012, use at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theSets = collectLayerSets(myDocument);
for (var m = 0; m < theSets.length; m++) {
          var thisSet = theSets[m];
          var myRegExp = /^\d{3}/;
          var theNumber = theSets.length - m;
          if (thisSet.name.match(myRegExp) == null) {thisSet.name = bufferNumberWithZeros(theNumber, 3) + " " + thisSet.name}
          else {thisSet.name = thisSet.name.replace(myRegExp, bufferNumberWithZeros(theNumber, 3))}
////// function collect all layersets //////
function collectLayerSets (theParent) {
          if (!allLayerSets) {var allLayerSets = 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 == "LayerSet") {
                              allLayerSets = allLayerSets.concat(collectLayerSets(theLayer))
                              allLayerSets = allLayerSets.concat(theLayer);
          return allLayerSets
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
          var theNumberString = String(number);
          for (var o = 0; o < (places - String(number).length); o++) {
                    theNumberString = String("0" + theNumberString)
          return theNumberString

Similar Messages

  • How to add 16 bit message sequential number to the byte array

    hi
    iam trying to implement socket programming over UDP. Iam writing for the server side now.I need to send an image file from server to a client via a gateway so basically ive to do hand-shaking with the gateway first and then ive to send image data in a sequence of small messages with a payload of 1 KB.The data message should also include a header of 16 bit sequential number and a bit to indicate end of file.
    Iam able to complete registration process(Iam not sure yet).I dnt know how to include sequential number and a bit to indicate end of file.
    I would like to have your valuable ideas about how to proceed further
    package udp;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class Sender  {
        protected BufferedReader in = null;
        protected FileInputStream image=null;
        protected static boolean end_of_file=true;
    /** pass arguments hostname,port,filename
    * @param args
    * @throws IOException
       public static void main(String[] args) throws IOException{
            DatagramSocket socket = new DatagramSocket(Integer.parseInt(args[1]));
            boolean more_messages = true;
              String str1=null;
                * gateway registration
                try{
                     //send string to emulator
                    String str="%%%GatewayRegistration SENDER test delay 10 drop 0 dupl 0 bandwidth 1000000";
                    byte[] buff=str.getBytes();
                    InetAddress emulator_address = InetAddress.getByName(args[0]);
                    DatagramPacket packet = new DatagramPacket(buff, buff.length,emulator_address,Integer.parseInt(args[0]));
                    socket.send(packet);
                        // figure out response
                    byte[] buf = new byte[1024];
                    DatagramPacket recpack=new DatagramPacket(buf,buf.length);
                    socket.receive(recpack);
                   // socket.setSoTimeout(10000);
                    String str2=str1.valueOf(new String(recpack.getData()));
                    if(socket.equals(null))
                         System.out.println("no acknowledgement from the emulator");
                        socket.close();
                    else if(str2=="%%%GatewayConfirmation")
                    //     String str1=null;
                         System.out.println("rec message"+str2);
                    else
                         System.out.println("not a valid message from emulator");
                         socket.close();
                catch (IOException e) {
                    e.printStackTrace();
                      end_of_file = false;
         /**create a packet with a payload of 1     KB and header of 16 bit sequential number and a bit to indicate end of file
      while(end_of_file!=false)
          String ack="y";
          String seqnum=
           File file = new File(args[2]);                               
                    InputStream is = new FileInputStream(file);                 
            socket.close();
      private byte[] byteArray(InputStream in) throws IOException {
             byte[] readBytes = new byte[1024]; // make a byte array with a length equal to the number of bytes in the stream
          try{
             in.read(readBytes);  // dump all the bytes in the stream into the array
            catch(IOException e)
                 e.printStackTrace();
            return readBytes;
      

    HI Rolf.k.
    Thank you for the small program it was helpfull.
    You got right about that proberly there  will be conflict with some spurios data, I can already detect that when writing the data to a spreadsheet file.
    I writes the data in such a way, that in each line there will be a date, a timestamp, a tab and a timestamp at the end. That means two columns.
    When i set given samplerate up, that controls the rate of the data outflow from the device, (1,56 Hz - 200 Hz),   the data file that i write to , looks unorderet.
     i get more than one timestamp and severel datavalues in every line and so on down the spreadsheet file.
    Now the question is: Could it be that the function that writes the data to the file,  can't handle the speed of the dataflow in such a way that the time stamp cant follow with the data flowspeed. so i'm trying to set the timestamp to be  with fractions of the seconds by adding the unit (<digit>) in the timestamp icon but its not working. Meaby when i take the fractions off a second within the timestamp i can get every timestamp with its right data value. Am i in deeb water or what do You mean!??
    AAttached Pics part of program and a logfile over data written to file
    regards
    Zamzam
    HFZ
    Attachments:
    DataFlowWR.JPG ‏159 KB
    Datalogfile.JPG ‏386 KB

  • Problem with layer sets opening

    Hi,
    I have a problem open layer sets. In my script I get layers index and then iterate throught this layers.
    Here is the script:
    function getAllLayersByIndex(){
           function getNumberLayers(){
           var ref = new ActionReference();
           ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID("NmbL") )
           ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
           return executeActionGet(ref).getInteger(charIDToTypeID("NmbL"));
           function hasBackground() {
               var ref = new ActionReference();
               ref.putProperty( charIDToTypeID("Prpr"), charIDToTypeID( "Bckg" ));
               ref.putEnumerated(charIDToTypeID( "Lyr " ),charIDToTypeID( "Ordn" ),charIDToTypeID( "Back" ))//bottom Layer/background
               var desc =  executeActionGet(ref);
               var res = desc.getBoolean(charIDToTypeID( "Bckg" ));
               return res  
           function getLayerType(idx,prop) {      
               var ref = new ActionReference();
               ref.putIndex(charIDToTypeID( "Lyr " ), idx);
               var desc =  executeActionGet(ref);
               var type = desc.getEnumerationValue(prop);
               var res = typeIDToStringID(type);
               return res  
           function getLayerVisibilityByIndex( idx ) {
               var ref = new ActionReference();
               ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Vsbl" ));
               ref.putIndex( charIDToTypeID( "Lyr " ), idx );
               return executeActionGet(ref).getBoolean(charIDToTypeID( "Vsbl" ));;
           var cnt = getNumberLayers()+1;
           var res = new Array();
           if(hasBackground()){
        var i = 0;
              }else{
        var i = 1;
           var prop =  stringIDToTypeID("layerSection");
           for(i;i<cnt;i++){
              var temp = getLayerType(i,prop);
              if(temp != "layerSectionEnds") res.push(i);
           return res;
           function getLayerVisibilityByIndex( idx ) {
               var ref = new ActionReference();
               ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Vsbl" ));
               ref.putIndex( charIDToTypeID( "Lyr " ), idx );
               return executeActionGet(ref).getBoolean(charIDToTypeID( "Vsbl" ));
    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 );
    var groups = getAllLayersByIndex();
        for(var i = groups.length-1; i >= 0 ; i--) {
          makeActiveByIndex( groups[i], true );
          ....working with layers....
    I think, my problem is in function makeActiveByIndex, because it doesn't make active a folder and doesn't open it.
    You can see it on this picture. Active layer set is "Skupina 1" and it is in layer set "hlavicka". But "hlavicka" is not open. WHY??
    Can you help me fix this problem??
    Thank you Domaneni

    Hi, for the past days I've worked on a script to toogle opening and closing layeSets, I've taken the code that TeddyBear posted here: http://ps-scripts.com/bb/viewtopic.php?p=14773 and adjusted it a little bit, and that's what I came up with, I hope it will help you:
    <javascriptresource>
      <name>BCM> ToogleOpen_CloseGroup...</name>
      <category>BCM</category>
    </javascriptresource>
    //For code readability
    // http://ps-scripts.com/bb/viewtopic.php?f=9&t=3235
    function getActiveLayerIndex() {
        var ref = new ActionReference();
        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
        ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
        return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));
    function cTID(s){return charIDToTypeID(s)}
    function sTID(s){return stringIDToTypeID(s)}
    // =============================
    // The main function
    function closeGroup(layerSet) {
       var m_Name = layerSet.name;
       var m_Opacity = layerSet.opacity;
       var m_BlendMode = layerSet.blendMode;
       var m_LinkedLayers = layerSet.linkedLayers;
      var currINDEX = getActiveLayerIndex();
       var m_bHasMask = hasLayerMask();
       if(m_bHasMask) loadSelectionOfMask();
       if(layerSet.layers.length <= 1) {
          addTempLayerSetIn(currSetIDX-1);
          makeActiveByIndex(currSetIDX+2, false);
          ungroup();
          groupSelected(m_Name);
          deleteTempLayerSetbyIdx(currSetIDX+1);
       } else {
           makeActiveByIndex(currSetIDX, false);
          ungroup();
          groupSelected(m_Name);
       var m_Closed = activeDocument.activeLayer;
       m_Closed.opacity = m_Opacity;
       m_Closed.blendMode = m_BlendMode;
       for(x in m_LinkedLayers) {
          if(m_LinkedLayers[x].typename == "LayerSet")
             activeDocument.activeLayer.link(m_LinkedLayers[x]);
       if(m_bHasMask) maskFromSelection();
       return m_Closed;
    // =============================
    // Below are all necessary subroutines for the main function to work
    function ungroup() {
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
       m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
       try {
          executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );
       } catch(e) {}
    function addLayer() {
       var m_ActiveLayer          =    activeDocument.activeLayer;
       var m_NewLayer             =    activeDocument.layerSets.add();
       m_NewLayer.move(m_ActiveLayer, ElementPlacement.PLACEBEFORE);
       return m_NewLayer;
    function hasLayerMask() {
       var m_Ref01 = new ActionReference();
       m_Ref01.putEnumerated( sTID( "layer" ), cTID( "Ordn" ), cTID( "Trgt" ));
       var m_Dsc01= executeActionGet( m_Ref01 );
       return m_Dsc01.hasKey(cTID('Usrs'));
    function activateLayerMask() {
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );
       m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
       try {
          executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );
       } catch(e) {
          var m_TmpAlpha = new TemporaryAlpha();
          maskFromSelection();
          activateLayerMask();
          m_TmpAlpha.consume();
    function deleteMask(makeSelection) {
       if(makeSelection) {
          loadSelectionOfMask();
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );
       m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
       try {
          executeAction( cTID( "Dlt " ), m_Dsc01, DialogModes.NO );
       } catch(e) {}
    function selectLayerMask() {
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));
       m_Dsc01.putReference(cTID("null"), m_Ref01);
       m_Dsc01.putBoolean(cTID("MkVs"), false );
       try {
          executeAction(cTID("slct"), m_Dsc01, DialogModes.NO );
       } catch(e) {}
    function loadSelectionOfMask() {
       selectLayerMask();
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putProperty( cTID( "Chnl" ), cTID( "fsel" ) );
       m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
       var m_Ref02 = new ActionReference();
       m_Ref02.putEnumerated( cTID( "Chnl" ), cTID( "Ordn" ), cTID( "Trgt" ) );
       m_Dsc01.putReference( cTID( "T   " ), m_Ref02 );
       try {
          executeAction( cTID( "setd" ), m_Dsc01, DialogModes.NO );
       } catch(e) {}
    function maskFromSelection() {
       if(!hasLayerMask()) {
          var m_Dsc01 = new ActionDescriptor();
          m_Dsc01.putClass( cTID( "Nw  " ), cTID( "Chnl" ) );
          var m_Ref01 = new ActionReference();
          m_Ref01.putEnumerated( cTID( "Chnl" ), cTID( "Chnl" ), cTID( "Msk " ) );
          m_Dsc01.putReference( cTID( "At  " ), m_Ref01 );
          m_Dsc01.putEnumerated( cTID( "Usng" ), cTID( "UsrM" ), cTID( "RvlS" ) );
          try {
             executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );
          } catch(e) {
             activeDocument.selection.selectAll();
             maskFromSelection();
       } else {
          if(confirm("Delete existing mask?", true, "Warning")) {
             activateLayerMask();
             deleteMask();
    function groupSelected(name) {
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putClass( sTID( "layerSection" ) );
       m_Dsc01.putReference(  cTID( "null" ), m_Ref01 );
       var m_Ref02 = new ActionReference();
       m_Ref02.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
       m_Dsc01.putReference( cTID( "From" ), m_Ref02 );
       var m_Dsc02 = new ActionDescriptor();
       m_Dsc02.putString( cTID( "Nm  " ), name);
       m_Dsc01.putObject( cTID( "Usng" ), sTID( "layerSection" ), m_Dsc02 );
       executeAction( cTID( "Mk  " ), m_Dsc01, DialogModes.NO );
       return activeDocument.activeLayer;
    function addToSelection(layerName) {
       var m_Dsc01 = new ActionDescriptor();
       var m_Ref01 = new ActionReference();
       m_Ref01.putName( cTID( "Lyr " ), layerName );
       m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
       m_Dsc01.putEnumerated( sTID( "selectionModifier" ), sTID( "selectionModifierType" ), sTID( "addToSelection" ) );
       m_Dsc01.putBoolean( cTID( "MkVs" ), false );
       try {
          executeAction( cTID( "slct" ), m_Dsc01, DialogModes.NO );
       } catch(e) {}
    function TemporaryAlpha() {
       activeDocument.selection.store((this.alpha = activeDocument.channels.add()));
       activeDocument.selection.deselect();
       this.consume = function() {
          activeDocument.selection.load(this.alpha);
          this.alpha.remove();
    function makeActiveByIndex( idx, visible ){
         if( idx.constructor != Array ) idx = [ idx ];
         for( var i = 0; i < idx.length; i++ ){
              var desc = new ActionDescriptor();
              var ref = new ActionReference();
              ref.putIndex(charIDToTypeID( 'Lyr ' ), idx[i])
              desc.putReference( charIDToTypeID( 'null' ), ref );
              if( i > 0 ) {
                   var idselectionModifier = stringIDToTypeID( 'selectionModifier' );
                   var idselectionModifierType = stringIDToTypeID( 'selectionModifierType' );
                   var idaddToSelection = stringIDToTypeID( 'addToSelection' );
                   desc.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
              desc.putBoolean( charIDToTypeID( 'MkVs' ), visible );
              executeAction( charIDToTypeID( 'slct' ), desc, DialogModes.NO );
    function deleteActiveLayer(){
       // =======================================================
       var idDlt = charIDToTypeID( "Dlt " );
           var desc752 = new ActionDescriptor();
           var idnull = charIDToTypeID( "null" );
               var ref529 = new ActionReference();
               var idLyr = charIDToTypeID( "Lyr " );
               var idOrdn = charIDToTypeID( "Ordn" );
               var idTrgt = charIDToTypeID( "Trgt" );
               ref529.putEnumerated( idLyr, idOrdn, idTrgt );
           desc752.putReference( idnull, ref529 );
       executeAction( idDlt, desc752, DialogModes.NO );
    function isLayerSet( idx ) {
         var propName = stringIDToTypeID( 'layerSection' );
         var ref = new ActionReference();
         ref.putProperty( charIDToTypeID( "Prpr" ) , propName);
         ref.putIndex( charIDToTypeID ( "Lyr " ), idx );
         var desc =  executeActionGet( ref );
         var type = desc.getEnumerationValue( propName );
         var res = typeIDToStringID( type );
         // alert(res);
         return res == 'layerSectionStart' ? true:false;
    function openGroup1(theGroup) {
       currSetIDX= getActiveLayerIndex();
       if(isLayerSet( currSetIDX ))
        getNamesPlusIDsOfLayerSet();
      makeActiveByIndex(currSetIDX, false);
    function getNamesPlusIDsOfLayerSet(){
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('Cnt '));
      var parId = executeActionGet(ref).getInteger(stringIDToTypeID( 'layerID' ));
       var Names=[];
       var x = 0;
       var y = 0;
       var r = 0;
       currINDEX = getActiveLayerIndex();
        var i = currINDEX;
       for(i; i > 0 ; i--){
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            var ls = desc.getEnumerationValue(stringIDToTypeID("layerSection"));
            ls = typeIDToStringID(ls);
            // alert(layerName+": _ :"+ls);
            if(ls == "layerSectionStart"){x++};
            if(layerName.match(/^<\/Layer group/) )
              y ++;
              r = x - y;
              if(r == 0 && ls == "layerSectionEnd"){break};
              continue
            if(ls == "layerSectionContent"){makeActiveByIndex(i,false);break};
            var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));
            var isLayerSet =( layerType == 'layerSectionContent') ? false:true;
    Names.push([[Id],[layerName],[isLayerSet]]);
    return Names;
    function getLayersNb()//function to find out if the number of layers in the document
        var ref = new ActionReference();
        ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID('numberOfLayers') );
        ref.putEnumerated( charIDToTypeID( "Dcmn" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
        var desc = executeActionGet(ref);
        var numberOfLayers = desc.getInteger(stringIDToTypeID('numberOfLayers'));
        return numberOfLayers;
    function toogleOpenCloseSet(){
      myALayerIDX = getActiveLayerIndex();
      myGroupP = app.activeDocument.activeLayer;
      if(!isLayerSet(myALayerIDX)){
          myGroupP = app.activeDocument.activeLayer.parent;
          if(myGroupP.typename != "Document"){
            if(isSetOpened1(myGroupP)){closeGroup(myGroupP)}else{openGroup1(myGroupP)};
      }else{
        if(isSetOpened1(myGroupP)){closeGroup(myGroupP)}else{openGroup1(myGroupP)};
    function getFristLayerSetChildVisible(){
      xx = false;
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('Cnt '));
      var parId = executeActionGet(ref).getInteger(stringIDToTypeID( 'layerID' ));
       var Names=[];
        var x = 0;
        var y = 0;
        var r = 0;
       currINDEX = getActiveLayerIndex();
        var i = currINDEX;
       for(i; i > 0 ; i--){
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            var ls = desc.getEnumerationValue(stringIDToTypeID("layerSection"));
            ls = typeIDToStringID(ls);
            var vis = desc.getInteger(stringIDToTypeID( 'visible' ));
            // alert(layerName+": _ :"+vis);
    /*        if(desc.hasKey(stringIDToTypeID("visible")))
              alert(desc.getType(stringIDToTypeID("visible")));
            if(ls == "layerSectionStart"){x++};
            if(vis == 1 && Id!=parId && r!=0){
              var theOBj = {id:Id, lname:layerName, idx:i};
              xx =true;
              Names.push(theOBj);
              break;
            if(layerName.match(/^<\/Layer group/) )
              y ++;
              r = x - y;
              if(r == 0 && ls == "layerSectionEnd"){break};
              continue
        return Names;
    function getLastChildIdx(){
      xx = false;
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('Cnt '));
      var parId = executeActionGet(ref).getInteger(stringIDToTypeID( 'layerID' ));
       currINDEX = getActiveLayerIndex();
        var i = currINDEX;
        var x = 0;
        var y = 0;
        var r = 0;
        var lastChIdx = 0;
       for(i; i > 0 ; i--){
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            var ls = desc.getEnumerationValue(stringIDToTypeID("layerSection"));
            ls = typeIDToStringID(ls);
            var vis = desc.getInteger(stringIDToTypeID( 'visible' ));
            if(ls == "layerSectionStart"){x++};
            if(layerName.match(/^<\/Layer group/) )
              y ++;
              r = x - y;
              if(r == 0 && ls == "layerSectionEnd")
                lastChIdx = i;
                break;
            // alert(x+" _ "+y+" _ "+r+" _ "+layerName);
        return lastChIdx;
    function getNbOfChilds(){
      xx = false;
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('Cnt '));
      var parId = executeActionGet(ref).getInteger(stringIDToTypeID( 'layerID' ));
       currINDEX = getActiveLayerIndex();
        var i = currINDEX;
        var nb = 0;
        var x = 0;
        var y = 0;
        var r = 0;
       for(i; i > 0 ; i--){
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            var ls = desc.getEnumerationValue(stringIDToTypeID("layerSection"));
            ls = typeIDToStringID(ls);
            var vis = desc.getInteger(stringIDToTypeID( 'visible' ));
            if(ls == "layerSectionStart"){x++};
            if(layerName.match(/^<\/Layer group/) )
              y ++;
              r = x - y;
              if(r == 0 && ls == "layerSectionEnd")
                break
              continue
            nb++;
        return nb;
    function isSetOpened1( group ){
      app.activeDocument.activeLayer = group;
      xx = true;
      currSetIDX = getActiveLayerIndex();
      addTempLayerSetIn(currSetIDX-1);
      var fIdx = getActiveLayerIndex();
      makeActiveByIndex(currSetIDX+2, false);
      if(fIdx == getActiveLayerIndex())
        xx = false;
      deleteTempLayerSetbyIdx(currSetIDX+1);
      return xx;
    function addTempLayerSetIn(idxx){
        // =======================================================
        var idMk = charIDToTypeID( "Mk  " );
            var desc58 = new ActionDescriptor();
            var idnull = charIDToTypeID( "null" );
                var ref63 = new ActionReference();
                var idlayerSection = stringIDToTypeID( "layerSection" );
                ref63.putClass( idlayerSection );
            desc58.putReference( idnull, ref63 );
        executeAction( idMk, desc58, DialogModes.NO );
        // =======================================================rename
        var idsetd = charIDToTypeID( "setd" );
            var desc202 = new ActionDescriptor();
            var idnull = charIDToTypeID( "null" );
                var ref209 = new ActionReference();
                var idLyr = charIDToTypeID( "Lyr " );
                var idOrdn = charIDToTypeID( "Ordn" );
                var idTrgt = charIDToTypeID( "Trgt" );
                ref209.putEnumerated( idLyr, idOrdn, idTrgt );
            desc202.putReference( idnull, ref209 );
            var idT = charIDToTypeID( "T   " );
                var desc203 = new ActionDescriptor();
                var idNm = charIDToTypeID( "Nm  " );
                desc203.putString( idNm, "mb-dummy tempTestLayerSetOpen_Closed" );
            var idLyr = charIDToTypeID( "Lyr " );
            desc202.putObject( idT, idLyr, desc203 );
        executeAction( idsetd, desc202, DialogModes.NO );
        // =======================================================move
        var idmove = charIDToTypeID( "move" );
            var desc59 = new ActionDescriptor();
            var idnull = charIDToTypeID( "null" );
                var ref64 = new ActionReference();
                var idLyr = charIDToTypeID( "Lyr " );
                var idOrdn = charIDToTypeID( "Ordn" );
                var idTrgt = charIDToTypeID( "Trgt" );
                ref64.putEnumerated( idLyr, idOrdn, idTrgt );
            desc59.putReference( idnull, ref64 );
            var idT = charIDToTypeID( "T   " );
                var ref65 = new ActionReference();
                var idLyr = charIDToTypeID( "Lyr " );
                ref65.putIndex( idLyr, idxx );
            desc59.putReference( idT, ref65 );
            var idAdjs = charIDToTypeID( "Adjs" );
            desc59.putBoolean( idAdjs, false );
            var idVrsn = charIDToTypeID( "Vrsn" );
            desc59.putInteger( idVrsn, 5 );
        executeAction( idmove, desc59, DialogModes.NO );
    function deleteTempLayerSetbyIdx(idxx){
      // =======================================================
      var idDlt = charIDToTypeID( "Dlt " );
          var desc = new ActionDescriptor();
              var ref = new ActionReference();
              ref.putIndex(charIDToTypeID( 'Lyr ' ), idxx);
              // ref.putIdentifier(charIDToTypeID( 'Lyr ' ), idxx);
              desc.putReference( charIDToTypeID( 'null' ), ref );
      executeAction( idDlt, desc, DialogModes.NO );
    toogleOpenCloseSet();

  • Control of layer sets in EDA objects

    We are using AutoVue in a process to review design library objects, as they are being created. We have a large number (10,000+) of these items to review and would like to make the user experience as simple as possible. One of the more cumbersome pieces of the review process is changing the visibility of layers. All of these objects have a common set of layers (same names and order). We are trying to determine if there is a way to simplify the layer visibility process. Here are a couple of thoughts we have and are looking for suggestions/alternatives.
    Option 1
    We know that a number of layer sets could be created where each set controls the visibility of a select set of layers. The layers sets could then be stored in a markup file. We know that the markup.map file controls the relationship between the object being viewed and the mark file. We could alter/programmatically update this file to have each of the objects point to the same markup file. This seems to be kind of a kludge and has a number of holes that make it not very desirable.
    Option 2
    We know that the UI can be altered depending on the user. We are thinking that if we could create menu items or icons that set the visibility for the various views the users need, it would make the process much more elegant and less time consuming. Several questions come to mind in this option. Can the UI be modified to add additional menu selection or icons? Can a menu item or icon be used to set the layer visibility? Can the method by which AutoVue is launched be used to control the ultimate appearance and options available to the user? If we were to pursue this option, is there a recipe already in place that could guide us through the process?
    Any and all responses are greatly appreciated.

    Hi Charlie,
    Thanks for clarifying that each of your EDA files have the same set of layers with the same names in the same order - this is a crucial factor if you want to try to approach this in a programmatic or batch manner.
    As we discussed earlier today in a separate thread, Option #1 (creating a single markup file with the saved views and linking that markup to multiple base files) might lead to problems. As you know, when AutoVue is not integrated to a DMS/PLM, the markups are managed on the AutoVue server in the markups.map file... and while that file is ASCII and could be modified (not recommended), remember that the mapping depends on exactly where the base file was opened from and what protocol was used to open that file. As a result, if the same file might be opened in 2 different ways (e.g. one time locally from the user's machine, and one time from a web URL), the markup won't automatically be linked to both. Option #1 might be too unpredictable.
    Therefore I'd recommend Option #2. I'll ask the experts to chime in if they disagree, but I think that what you'd like to achieve is possible through the AutoVue API and can be broken down into 3 parts:
    1. Writing the core code to enable/disable specific layers
    2. Packaging this code as a custom "VueAction" so that it can be called as a custom menu or toolbar item
    3. Customizing the GUI to expose this menu or toolbar item
    Part 1 (code to enable/disable specific layers) should be relatively easy. The AutoVue API includes a class called "com.cimmetry.core.PAN_LAYER" which represents a layer in a file (including EDA files). With the API you can:
    - Get the list of layers from the current file (VueBean.getLayersState)
    - Enable/disable the layers as required (PAN_LAYER.setState(PAN_LAYER.STATE_ON) or PAN_LAYER.setState(PAN_LAYER.STATE_OFF))
    - Re-apply the updated layer set (VueBean.setLayersState)
    Part 2 (building a custom VueAction) is a bit more complex, but is explained quite well in the new API Programmer's Guide (http://download.oracle.com/docs/cd/E22156_02/otn/pdf/E22092_01.pdf) that shipped with AutoVue 20.1.0. I'd recommend to read pages 20-22 and 30-35. You would want to take the code from Part 1 and package it into your custom VueAction's "perform" method.
    Part 3 (customizing the GUI) should also be relatively easy, and is discussed on pages 62-68 of the Installation and Configuration Guide (http://download.oracle.com/docs/cd/E22156_02/otn/pdf/E22093_01.pdf).
    But rather than just saying "read the docs", we also now provide a pre-written example of a custom VueAction with AutoVue 20.1.0 Client/Server Deployment (I think it's an optional component during install). If you've included it during the install, you'll have the folder \examples\VueActionSample in your server installation. You should be able to use that as a reference for adding your own custom VueAction to the applet.
    There's one other part I hadn't included. In our separate thread earlier today, I think you mentioned you wanted to only provide this GUI customization for certain users. If you want to control the GUI based on user/group/role/etc, this is possible but will be up to you to determine the user/group/role/etc and script the JVue applet accordingly (i.e. either dynamically script the applet to set the GUIFILE parameter, or use the JVue.setGUI method).
    Hope this helps as a start.
    Thanks,
    Graham
    EDIT: If you prefer to automate the layer config as soon as the file is loaded - rather than have it as a custom menu or toolbar item - you can do that as well and in fact it's much easier. In that case you still go through Part 1 and write the code to set the desired layers, and you implement it as a 2nd applet as described in Oracle KM Note 754612.1 (https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=HOWTO&id=754612.1).
    Edited by: user638792 on Apr 5, 2011 8:23 PM

  • Can Aperture Read the camera's sequential number metedata when naming files

    Before I started using Aperture I would use this naming convention in Bridge to batch rename files and It works great because it avoids duplicate file names and the files are in sequential order
    my last name(Blake)YYYYMMDDfour digit NON RESETTING sequential number, generated by my Nikon D2X. I don't have any duplicate file names unless I shoot more that 9999 images in one day.
    Has anybody found the option to use the camera's generated sequence number in Aperture's file naming scheme. I sure can't. I know that you can set a four digit sequence but that sequence doesn't start where the sequence leaves off in the previous import.
    Thanks
    John
    G4 Powerbook   Mac OS X (10.4.8)  

    I have two workarounds
    1. Rename the files in bridge after like I have always done and then import the folder as an Aperture project without changing the file names. I use photo mechanic to download the files from the card.
    2. Go to the library smart folders to see what was the last project I imported and check the four digit sequence before the file name extension. Set the sequential counter in Aperture to start at the next sequential number where the last file left off.
    I have to use the four digit sequence instead of using the date and Time sequence. It is very convenient for my clients to give me the four digit sequence when telling me what images they want prints from,etc. Avoids any confusion.
    I did request this feature of using the camera's generated file name in Apple's feedback link for future inhancements.
    thanks for your responses
    John
    G4 Powerbook   Mac OS X (10.4.8)  
    G4 Powerbook   Mac OS X (10.4.8)  

  • Sequential Number for Non-Approved Forms

    Hello-
    I'm building an InfoPath form that is submitted to a SharePoint library.  There is an approval workflow created in SP Designer.  Once the form is approved, it is moved to another document library and then deleted from the current one.  Our
    goal is to assign a sequential number (RQNumber) to each form.  In InfoPath I have created 2 fields:  One that looks in the initial form library and grabs the max RQNumber and another that looks in the other form library and grabs the max
    RQNumber.  Then I have a field that takes the max of those two numbers and adds 1.
    The issue I'm having is I can't get the formula to grab the max RQNumber from the first form library.  I'm guessing this is because the form hasn't been approved yet, so it doesn't pull from the form until it's approved.  Is that correct? 
    Is there any way around that?
    Thanks! 

    Hi Nivek,
    Question: At what stage is the RQNumber assigned to the form in the first form library? Is it during submission of the form or during approval? If you are deleting the document from the first form library, arent you getting the max RQNumber same everytime?
    If this number is assigned during form creation, you should be able to lookup in the form library from a data connection to the same form library. During Form load, set a field to have max of RQNumber. Hope it helps.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

  • Min and Max of sequential number

    Hello
    I have a table called pins (lot number(4),
    sequence number ( 8)
    In the table I have data:
    lot sequence
    386 100
    386 101
    386 102
    386 800
    386 801
    387 1
    387 2
    I want to know by lot the low and high values for sequential number, the result I am looking for is
    lot min(sequnce), max(sequence)
    386 100 102
    386 800 801
    387 1 2
    Oracle 10g rel2
    Thanks

    Hi,
    You want something like this:
    WITH       got_grp     AS
         SELECT     lot
         ,     seq_num          -- SEQUENCE is not a good column name
         ,     seq_num - ROW_NUMBER () OVER ( PARTITION BY  lot
                                                      ORDER BY      seq_num
                                          ) AS grp
         FROM    pins
    --     WHERE     ...     -- any filtering goes here
    SELECT       lot
    ,       MIN (seq_num)          AS min_seq_num
    ,       MAX (seq_num)          AS max_seq_num
    FROM       got_grp
    GROUP BY  lot
    ,            grp
    ORDER BY  lot
    ,            min_seq_num
    ;As I understand the probem, you want to GROUP BY, but lot doesn't define the groups by itself: each contiguous set of seq_nums in a lot is a separate group. In each of those groups, the difference between seq_num and a counter reflecting the order of seq_num generated in the query (using ROW_NUMBER) will be constant.
    This assumes that seq_num is an integer, and that (lot, seq_num) is unique.
    If not, the query above will need a little adjustment.
    If you'd like to post INSERT statements for your sample data, then I could test this.

  • Is there a way to sequentially number repeating calendar events

    Is there a way to sequentially number repeating calendar events?
    For example: I have fitness training 3x a week, every Tue, Thu & Sat. I  set it up as a repeating event in calendar, but would like it to nimber each event. o if I looked at the last day on the calendar, there would have been noted somewhere that this was occurence #12 Currently, I would have to go ahead into each event & edit in what # it was. Any help or suggestions  would be appreciated. Thanks!

    I don't believe that there any automatic way to do this in the Calendar App.

  • Sequential number visible to user

    Is it possible to have a field which shows a distinct sequential number for each form? I want to set up a Purchase Order system where a distinct number is visible to the person filling out the form online.

    This is not supported by Adobe FormsCentral.  This is something that you would be able to achieve using pdf forms created in Acrobat Pro.
    -Jeff
    Jeff Canepa
    Software Quality Engineer
    Adobe Systems, Inc.
    [email protected]

  • Tax report for Spain - Sequential Number

    The layout that I have prepared for the Tax report (RFUMSV00, Tx: S_ALR_87100833) shows the column "Sequential number." Thus, I have a relationship without jumping straight to the numbering of all invoices with VAT.
    The system assigns a "Sequential number" for SAP document number. The "problem" arises when there is a bill, a SAP document, with more than one tax indicator of VAT. Then some lines appear in the Declaration of VAT with the Sequential number field in blank and that is because the number of the document (this bill) is already listed in the Declaration in another line with its own Sequential number .
    How do you work with it? Can I somehow avoid that remove this Sequential number blank?

    Hi (again)
    After reading the SAP note number 1628714 ( https://websmp107.sap-ag.de/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM=1628714&_NLANG=E ), I think that there isn't an SAP-standard solution.
    Best regards.
    Paco M

  • Photosho CS Problem - Can't drag a layer set from one document to another one

    I have two documents open
    On the source document, i want to drag a layer set from this document to a new one, but its not letting me
    What would cause this.
    My structure for the source document is
    >Set 1 Layer Set
         >layer
         > Adjustment Layer
         >background
    Background
    Structure of the target document
    >Named Layer Set
         > Where I want to insert the Layer Set from source document
         >layer
         > Adjustment Layer
         >background
    Background

    No error message is given. I just can't drag it into the spot I want to drag the layer set to (its not an individual layer, its a layer set)
    Basically, this is all I can do (have to do a correction on how the layers and layer sets work, missing one level from the original post):
    I've attached images as well to illustrate
    On my target document, I want to have the layer set go where the red text is:
    >Content Layer Set
         >Named Layer Set
              > Where I want to insert the Layer Set from source document (Set 1)
              >layer
              > Adjustment Layer
              >background
    Background
    right now, I can only drag the layer set to this position:
    >Content Layer Set
          > This is where the Set 1 from the source document can go, I can't drag it into the layer set below
         >Named Layer Set
              >layer
              > Adjustment Layer
              >background
    Background
    First Image I attached shows the Set 1 Layer Set, above the layer set I want to drag it into
    Second Image I attached shows what happens when I try to drag the layer set into the named layer set; it comes up with the "no symbol"
    No Error message is given

  • Changing from "Pass Through" as Default in Blend Mode in a Group Folder Layer Set

    Hello Forum gurus!
    Using a MacBook Pro, 10.5.4. Painting with CS2. My question is two-fold.
    When the Group layer folder in a layer set is selected, it is displaying the "Pass Through" blend mode by default. Is there a special convenience to this? (Best use for pass through blend mode)
    Also, How may I change the default in this mode to be "Normal" as the setting when creating a Group folder layer set?
    Thanks!!
    Colene

    Matthias, now I understand. We're both right from different perspectives. If you want the adjustment layer (should there be one within the group) to affect all layers below the group (perhaps because that's the way the image looked before you made the group in the first place), then Pass Through is your blend mode. If you want that adjustment layer to affect only those layers within the group (which I often do), then Normal (or some other) is your blend mode.

  • How I can change sequential number in RFUMSV00 (Spanish declaration of VAT)

    Hi!
    How I can change sequential number of Output /Input Tax in RFUMSV00 transaction (Spanish declaration of VAT)?
    In input declaration I would like to have one sequential number for input tax and for output tax that appears on in.  Is possible with standard Sap or I need a Z-transaction?
    Thanks

    Dear friend,
    Please refer the below note.
    SAP Note 849459
    Reg
    Madhu M

  • My husband and I both have iPhones on the same account. When he did his update yesterday, he chose both his number and my number during set up. Now he is getting my messages, too. Can someone please help me fix this?

    My husband and I both have iPhones on the same account. When he did his update yesterday, he chose both his number and my number during set up. Now he is getting my messages, too. Can someone please help me fix this?

    What do you mean he chose his and your number during setup. Chose them for what? Is you number showing up in the Settings>Messages>"You can be reached by imessage at" section? If it is he needs to remove it.
    Cheers,
    GB

  • Sequential number

    Hi All,
    What is the importance of  Sequential number for condition exclusion in Pricing Proce. where we assign one exclusion grp to other? How should i arrange the sequence of assignements of different exclusion groups?
    Can a exclusion group  contains more than one conditon type for comparision?
    Thanks,
    Pramod

    Hi madhu aaryaa,
    I think that you have some problem with you.
    You had posted similar question for the past 2 or 3 times and I had replied for them. You have not even rewarded points or closed them.
    Check these threads for your reference...
    logic generation
    number generation
    batch number
    batch number
    I have even posted the code for this. Hoping that you will do the needy...
    PARAMETERS p_i TYPE i.
    DATA d_i1 TYPE i.
    DATA d_i2 TYPE i.
    DATA d_i3 TYPE i.
    DATA d_i4 TYPE i.
    DATA code(4).
    DATA num(36) VALUE '0123456798ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
       d_i4 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i3 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i2 = p_i MOD 36.
       p_i = p_i DIV 36.
       d_i1 = p_i MOD 36.
       code+0(1) = num+d_i1(1).
       code+1(1) = num+d_i2(1).
       code+2(1) = num+d_i3(1).
       code+3(1) = num+d_i4(1).
       WRITE code.
    Message was edited by: Wenceslaus G

Maybe you are looking for