Duplicate the layer just above the layer source by script

Hello

I'm trying to duplicate the layer by using script. Layer duplicated only taking place at the beginning of the order of the layers. I want the duplicate layer just above the layer.

I got this forum.

var docRef = app.activeDocument;  
with(docRef) {  
         var ll = docRef.activeLayer ; 
         var ln=ll.name;
         var ol = layers.getByName(ln);  
               ll.visible = false;  
        var nl = layers.add();  
         nl.name = 'Duplicated Layer';  
         for (var a = ol.pageItems.length-1; a >= 0; a--) {  
              ol.pageItems[a].duplicate(nl, ElementPlacement.PLACEBEFORE);  
              nl.visible = true;
         }  
    }  

//~ ElementPlacement.PLACEBEFORE); // moves it above a group named 'my group' in the stacking order  
//~ ElementPlacement.PLACEAFTER); // moves it below a group named 'my group' in the stacking order  
//~ ElementPlacement.INSIDE); // moves it inside a group named 'my group', at the top of the stacking order  
//~ ElementPlacement.PLACEATBEGINNING); // moves it inside a group named 'my group', at the top of the stacking order just like ElementPlacement.INSIDE  
//~ ElementPlacement.PLACEATEND);

Screen Shot 2016-06-28 at 11.20.59 AM.png

I duplicated the layer 2 and place it at the top. Strange.

Help, please

Kind regards

Kitty

Try this code...

var docRef = app.activeDocument;
with(docRef) {
    var ll = docRef.activeLayer ;
    var n=docRef.layers.length;
    x=ll.zOrderPosition;
    var ln=ll.name;
    var ol = layers.getByName(ln);
    ll.visible = false;
    var nl = layers.add();
    nl.name = 'Duplicated Layer';
    for (var a = ol.pageItems.length-1; a >= 0; a--) {
        ol.pageItems[a].duplicate(nl, ElementPlacement.PLACEATBEGINNING);
        nl.visible = true;
    }
    docRef.layers.getByName("Duplicated Layer").move(docRef.layers[n-x], ElementPlacement.PLACEAFTER);
}

-yajiv

Tags: Illustrator

Similar Questions

  • Put the pictures side by side + change layer source?

    I'm doing the following with a large amount of images named by chronological order:

    -duplicate a layer

    -Move to the right by the amount of its width

    -change its source of layer so the image is in order:

    [1] [2] [3] [4]


    The first image is called "IMG_1.jpg", the next "IMG_2.jpg" etc.


    So far, I found a way to move the layer duplicated to the right using this expression:


    thisComp.layer(index+1).transform.position + width


    Now I just need a way to define the source of the layer count + 1, also in a way like this:

    source. Name = IMG_ '+ 1'.jpg


    Is it possible to do this? Thanks for your help.


    To replace a layer with another source you select the layer in the timeline panel, and then select the new source in the project Panel, then hold down the Alt/Option key and drag the replacement layer to the project in the timeline panel and release the mouse button. All you have to do is to get the replacement layer anywhere in the timeline and it will replace the selected layer and take all of the properties of the layer.

    There is no way to do it automatically with an expression, but you can write a script that would replace all your layers at a time.

    This info available and more explanation is offered if you type "replace images in the timeline" in the search field help in the upper right of the AE

    I would probably approach this problem by selecting all images in the project Panel and then select new Composition of selected, then select single composition, then use the Panel align to align the images, and then animate the first image and the rest of the images to one of the parents.

    Perhaps even better option to create a file in Photoshop or Illustrator layered with all elements lined up, imports a model and then use the trick of parenting.

    If you need compensate animations so things are moving a layer at a time, then I would like to animate the first layer, create a preset, and then move the CTI to the start time of the next layer and apply the preset animation.

    I hope this helps.

  • When I try to duplicate a layer from one file to the other why appears a window of "displacement"?

    When I try to duplicate a layer from one file to the other why appears a window of "displacement"? What should I do?

    Never seemed this before.

    Thank you

    I can't reproduce this. The layer as you try to duplicate a smart object and there a displacement map? Looks like you might need to reset your preferences.

  • How to duplicate the layer and rename it?

    Greetings to all.

    I do a little tool, and I need to duplicate the layer, change of name and so...

    Tell me how to change the name of the layer? After all, when duplicate layer app.activeDocument () of the range slider layer remains on the same layer. Can be done through hard brace, but I think that there is a simpler solution.

    Thank you

    Layers have a name property that can be changed via the Script.

    2014, use it at your own risk.

    #target photoshop

    If (app.documents.length > 0) {}

    theDoc var = app.activeDocument;

    var theLayer = theDoc.activeLayer.duplicate (theDoc.activeLayer, ElementPlacement.PLACEBEFORE);

    theLayer.name = "test";

    theDoc.activeLayer = theLayer

    };

  • Duplicate the layer

    I have been writing scripts in Photoshop and you need to convert my script to Illustrator.

    I use the VBScript/Javascript program and also in .net with VB and c# to create programs for Photoshop / Illustrator

    In Photoshop, you have layer.duplicate to duplicate a layer with all of its contents, but I can't seem to find the correspondent for Illustrator.

    In the window of the layers in Illustrator, you can select a layer and then in the dropdown in the layer window, select duplicate 'NomCouche' I looked at the script reference and can't seem to find a solution.

    Thanks in advance.

    Sorry, the example you have a layer of higher level called "Layer 1" present in the document is waiting for you try to re-enter all the pageItems. "." As is, it does NOT the nested layers under what you need to address recursively through those if necessary.

  • How to duplicate a layer and then change the adjustment layer?

    This used to be easy to PS7, but he is evasive in CS4. Sometimes we need to duplicate a layer, then change the adjustment layer. For example, we may have selected a portion of an image and used the brightness contrast and then we need to create a new layer using the same section using selective correction. What we have done in the past, is to duplicate the layer, and then change the adjustment layer. Any ideas?

    Create your new adjustment layer. Option drag the mask layer on the new original setting, and then choose replace.

    Beware of the many similar masks:

    http://www.teddillard.com/2008/10/Geekzone-rosenholtz-Sanchez-effect.html

  • How to add a path just above a selected path targeted in the layers palette?

    I put it in the feature request but maybe its already possible right in front of me... I have a few layers or layers sup with many paths, often I'll remove a path and want to replace it with another way of access, but in the same order of stacking against the railways in its layer. I thought I would click on select the path in the path, I deleted the layers stack and draw my new path in the document window to have it appears higher than selected path, but for me, I find that the new path is placed at the top of the stack, which could be 50 paths above for example... so I have to scroll up to find in the layers palette and drag in back down to the position I want, in layers of stack, just above the path I had chosen before shooting the new path.

    I would rather just to select the specific path, I want to attract higher up in the stack of layers and then draw in the document window, the new path will be added on top of this path, I selected in the layers palette...

    is there an easier way? am I missing something?

    I know that there is an order now maintained by illustrator, the last path is placed up in the drawing sequence. fine. But I was hoping a command could be programmed in where we can click on the 'target' circle in the layers palette to mean that we want the next course plotted above this target selection... something like that.

    where my explanation was a little wordy, here's an example, the way that I drew ends by upstairs, instead of above the trail, I selected below in the battery... hoping if I target this way below by clicking its target circle, the next path would be above him. of until I have clear this path with CTRL/CMMD by clicking on the button of his target, which would free the sequence of drawing of this target base and default back up to the top of the stack in this layer.

    selectedPath.jpg

    You can try to double-click the path to go into Isolation mode.

    Then draw the new path and press ESC.

    This should give you a new path directly above the trail double you clicked.

  • Is there a way to FF4 can I change the layout of the screen so I can have the tabs just above the pages, as in FF3.6.18?

    Hello

    I run FireFox (FF) for years and love. I'm running FF 3.6.18 am thought and upgrade to FF4. However, a friend upgraded to FF4 and I notice that the tabs for different pages are very high on the screen, away from the pages concerned, instead of just at the top of the page being displayed, where they are more easily found and used. Having the tabs at the top is really annoying and it is a change that should never have been done.

    My question is this: is there a way to FF4 I can change this so I can have the tabs just above the pages, as in FF3.6.18?

    Thank you very much
    Al

    Yes! Click the new tab button ("+") or a blank space after the last tab and uncheck tabs on top in the context menu.

    If the tabs on top does not appear there, you can use the view menu:

    Menu view > toolbars > uncheck tabs on top

    If you have the Firefox orange (abbreviated menus) button, press the ALT key, or press F10 to display the classic menu bar to join the view menu.

    (Oh, it will make more sense after you install Firefox 5 does it by looking at Firefox 3.6)

  • How the 4.01 version to have the TABS line nearby even as in 3.67. ?. In other words, the line of TABS just above window web site at 3.67. Right, in 4.01, is now in the top line of the screen.

    Basically, need a feature that allows the user to rearrange the location of tab line (ie: the ability to drag the line to a different location). For me, it would be moved from the line Summit of 4.01 on line facing down(as the place where it sits in versions of X 3.6), just above the window of the web page. That would make it very convenient to click on multiple back when necessary. What I constantly in my case.

    I thank you for your public service and a great work all you do!

    You can right click on the orange Firefox button to open the menu of the toolbar.

    • Click "Tabs at the top" to remove the check mark and place the tab to its original position bar just above the browser window.
  • While hovering just above my trackpad, it will be 'click' in itself Apple cleaned my trackpad and assured me that there is no place on the Mac to set or change this option.

    While hovering just above my trackpad, it will be 'click' in itself Apple cleaned my trackpad and assured me that there is no place on the Mac to set or change this option.

    Which option?

  • In the left pane of Windows Live Mail, my four email accounts including pointed "Windows Live Mail, just above Gmail, but now they're gone."

    In the left pane of Windows Live Mail, my four email accounts including pointed "Windows Live Mail, just above gmail.   He disappeared somehow (I probably errased it instead of an email.)  and I would like to know how to back this account to the left pane. This would indicate how many emails were waiting in the Inbox.  If there is a suitable forum that I missed, FEAL free to direct me there.

    original title: account list in windows live mail.

    Please repost in Windows Live Solution Center.

    Mail-forum - section of son of mail:

    http://windowslivehelp.com/forums.aspx?ProductID=15

  • My XI Acrobat Standard 11.0.09 lost menu bar (F9) and crazy jumps full screen, losing windows buttons high bar, passing just above the menu bar with the mouse cursor, without clicking.

    My XI Acrobat Standard 11.0.09 lost menu bar (F9) and crazy jumps full screen, losing windows buttons high bar, passing just above the menu bar with the mouse cursor, without clicking.

    Yes, it's important somehow. Kapersky broke it somehow and fixed. http://Forum.Kaspersky.com/index.php?showtopic=307391&HL=Adobe

  • Is it possible to use scripts to duplicate a layer?

    I recently asked this question in the Illustrator forum that I did not know there was a separate script forum: find and replace text problem

    I finished just dangling down and solve my problem after spending a few hours just to experiment with script guide.

    Now, I'm finishing the final piece of the puzzle for this script which would be totally solved my problem. Is it possible to make the script duplicate a layer? There is a duplicate() function, but it seems not to apply to the layer element. Is there a work around?

    Thanks for your help

    Michael

    Regarding javascript:
    -CS5, you must name a new layer, called the same name as your source for baptism layer and then duplicate each element of the source for the new layer.

    Be aware that things such as graphical styles, layer, opacity masks on layers and sublayers don't get carried forward like that.

    However, with the CS6 + that allows a script to play an action, you can actually get "whole enchilada" by recording an action where you go into the menu drop down and use the "Duplicate" command This will save "layers > duplicate Selection" in action. Then, you can use javascript to target your desired layer and play this action. Your new layer will be a string of "copy" added automatically, so you can choose to delete or modify that.

  • after effect to duplicate the issue of the composition: in the 2nd composition, change the first

    I downloaded free after effect models.

    after effect to duplicate the issue of the composition: in the 2nd composition, change the first

    This means that if I write "Ahmed" for the second, one automatically becomes even.

    I'm new in after effect. I have less idea of 'Master of composition and scene files.'

    How can I fix happening like that?

    simpler.jpg

    You should get some basic skills in After Effects.  It is not a program, you can just start using without having to learn the basics and expect to have success at all.

    That being said here, that's what you need to do.

    Comp 2 duplicate in the project (not the layer panel) Panel in order to have a '3 Comp '.  Add a layer to 1 Comp.  Now modify Comp3, and you will see the difference.

    Understand that Comp2 will always be Comp2 little matter how many times you duplicate in the layer panel.  Whenever you make a change to Comp2 that change will be seen in each layer named Comp2 any composition it is nested in. That's what you need to do.

    I just gave you a fish, but it won't last long.  Soon you will ask for another.  So now, I'll give you a fishing rod: you must learn how nesting compositions in After Effects.   You must take some time to learn the basics of After Effects, or else you're going to be here every day asking why this, why that. Every day ask for a fish.  You can simply download a model and expect to be able to use it.  It is an unrealistic expectation. .

  • Mail body blank when mail is sent by the java source compiled.

    create or replace and compile java source named MailExMulti as
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.net.URL;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Properties;
    import javax.activation.DataHandler;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.mail.BodyPart;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletRequest;
    import javax.servlet.http.HttpServletRequest;
    import java.sql.Clob;
    public class SendSimpleMail {
      public static void sendmail(String s) {
          Properties props = new Properties();
           props.put("mail.smtp.host", "xxx.xxx.com");
           props.put("mail.smtp.socketFactory.port", "123");
           props.put("mail.smtp.socketFactory.class",
                           "javax.net.ssl.SSLSocketFactory");
           props.put("mail.smtp.auth", "true");
           props.put("mail.smtp.port", "123");
            Session session = Session.getInstance(props,
              new javax.mail.Authenticator() {
              protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("[email protected]", "aaa");
              }
              });
            try {
              MimeMessage msg = new MimeMessage(session);
    javax.mail.Multipart multiPart = new MimeMultipart("mixed");
    MimeBodyPart textpart = new MimeBodyPart();
    textpart.setText("\r\nasdsadsadsad");
    multiPart.addBodyPart(textpart);
              msg.setFrom(new InternetAddress("[email protected]"));
              msg.setRecipients(Message.RecipientType.TO, "[email protected]");
              msg.setSubject("Simple Test Mail");
              msg.setSentDate(new Date());
             
              msg.setContent(multiPart);
              msg.saveChanges();
              File file;
              file = new File("D:"+"//msg1.txt");
              try{
              msg.writeTo(new FileOutputStream(file));
              }
              catch(Exception e)
              {
              System.out.println("File does not exists...");
              }
              Transport.send(msg);
        System.out.println("---Done---");
            } catch (MessagingException mex) {
            mex.printStackTrace();
            }
      }
    }
    
    

    When we call the java source above for pl/sql an empty body is sent to the recipient, so that if I copy this code and work in stand-alone jdk the recipient is able to see the body. Any help would be greatly appreciated.

    If we directly set html in msg.setcontent without recipient multipart, is able to see the body.

    But I need to make this work with addbodypart and several parts that I intend to integrate images later in the mail.

    Oracle DB version: 11.2.0.2.0

    used container: javax.mail - 1.5.0.jar

    That may be relevant to the multipart construction, but that's just a guess.

    With the help of Java to send mails to the database is no longer really needed. There is UTL_SMTP and UTL_MAIL:

    https://docs.Oracle.com/CD/E11882_01/AppDev.112/e40758/u_mail.htm#ARPLS384

    UTL_SMTP

    Or this thread: need help with sending e-mail s

Maybe you are looking for