Illustrator Script: How can I duplicate a layer ( with sublayers ) with javascript code ?

Dear All
I want to duplicate a layer structure, as the "Duplicate Layer" submenu do with Javascript code, but I can't.
I can duplicate only PageItems or selected object, but no Layers.
Anybody knows how can I do it ?

Thanks for your answer.
#target illustrator 
var docRef = app.activeDocument; 
var ln = 'Layer 1'; 
var ol = docRef.layers.getByName(ln); 
var nl = docRef.layers.add(); 
nl.name = ln+' Copy'; 
for (var a = ol.pageItems.length-1; a >= 0; a--) { 
    ol.pageItems[a].duplicate(nl, ElementPlacement.PLACEATBEGINNING); 
The problem with this code is, that it can't duplicate also the sublayers, and the sublayer elements.
Sure I can write a recursive function, but I think there should exist a duplicate function somewhere ( for Photoshop script exist ! ) or a small trick, but I can't find it.
Thanks

Similar Messages

  • How can I group two annotations with JavaScript?

    I create two annotations with JavaScript:
    var annot1 = this.addAnnot({
                      page: 0,
                      type: "Square",
                      rect: [150, 150, 180, 180],
                      name: "OnMarketShare",
                      author: "A. C. Robat",
                      contents: "This section needs revision."});
    var annot2 = this.addAnnot({
                      page: 0,
                      type: "Square",
                      rect: [200, 200, 300, 300],
                      name: "OnMarketShare",
                      author: "A. C. Robat",
                      contents: "This section needs revision."});
    How can I group them with JavaScript?

    Can I select them in JavaScript Code?
    like:
    annot1.selected = true;     //wrong JavaScript code.
    annot2.selected = true;     //wrong JavaScript code.
    annot3.selected = true;     //wrong JavaScript code.
    annot4.selected = true;     //wrong JavaScript code.
    If I can do these, I can group them easily : right-click them, and then, click "group" button.

  • How can I hide a button with javascript in Captivate 8?

    I need to run some javascript in my project and at the same time I want to hide a button, so I can't use advanced actions.

    It is very strange, most users who have focus on JS try to do everything with it, whereas lot of simple actions can easily be done with advanced/shared actions. I will only go to JS when it is not possible with advanced/shared actions.
    You are lucky, I was just restarting to work on an advanced training for next week when your question showed up.

  • How do i transform a layer with maintain aspect ratio through scripting in Photoshop?

    Hi,
         How do i transform a layer with maintain aspect ratio through scripting in Photoshop? I am expecting your reply.
    thanks,
    Rajiv.s

    I don't think your talking apples to apples.  First I do not know of any Maintain Aspect Ratio icon in Photoshop. The only icon I think associated with transform is the anchor point icon in the option bar for transform. I think you may referring to the constrain check box in the image size dialog which you can check when resample is checked. Image size effect all layers in the document and the documents canvas size. The document canvas size will be changed to the values in the images size dialog and all layers will be transformed by percentage the canvas was changes while maintaining the layers position over the canvas and the layers I think may be cropped so only pixels over the canvas remain.
    I do not know if you know that layers can be any size and have aspect ratios different then the documents canvas.
    In your case it sounds like your describing a template that has a canvas size that is 2000px wide be 3000px high a 2:3 portrait aspect ratio.  Your image file has a landscape aspect. If you place that image into your template place would by default transform the image so the image would fit within the 2000px by 3000px canvas size there would be a white border top and bottom.  You could transform that smart object layer to it actual pixels size activeDocument.activeLayer.resize(100,100, AnchorPosition.MIDDLECENTER); then calculate the size you want to transform its height to. By retrieving the canvas size and the layers boundaries. Divide the canvas height pixel size by the layers pixel height size should give you the percentage you need to use. Make sure you set the ruler units to pixels so your working with pixel values for the canvas and layer size values. The resulting layer will be larger then canvas size keeping the anchor point centered will result in the canvas size masking off both sides.  In effect cropping you landscape to a portrait.  Note cropping a image from one orientation to the other changes the composition drastically.
    If your trying to make a composit like collage you may want to look at my Photoshop Collage Toolkit it will fit images to fill a 2000px by 3000px area http://www.mouseprints.net/old/dpr/PhotoCollageToolkit.html
    You could also do centered 2:3 crop that is resized to a 3000px

  • How can I duplicate a control in a subVI using the reference?

    Here's what I want to do. I have a tree control in my main application. I add and delete items dynamically based on user input. If I pass my tree reference to a subVI, I can add, subtract and reorder the items in the tree and the changes are shown on the main tree. How can I duplicate the tree in the subVI? Would I simply pass the tree control in (which I'd rather not do) or is there some other way to accomplish this?
    Thanks in advance for any help.
    Gary

    Here's my attempt.  This VI uses a control reference of the old tree and generates a data structure that can be used by the "Edit Tree Items.Add Multiple Items to End" method to add contents to the new tree that should be identical to the contents of the original tree.  Note that this VI only works with LabVIEW 8.0 and later, since the afore-mentioned method is not available in previous versions.
    I hope this helps...also note that I saw some re-draw issues with LabVIEW 8.0, i.e. after the VI ran, I didn't see the tree displayed properly until I minimized/restored the window, or dragged another window over it.  I did not see the redraw issues in LabVIEW 8.2.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    Duplicate Tree.vi ‏21 KB

  • How can I duplicate a photo in the Ipad photo program?

    HOw can I duplicate photos in the original ipad photo program? I wanted to blow up a part of a picture, but also keep the original.

    The Photos App keeps the original with editing added as changes to the original. You can always revert back to the original.
    Other photo editing Apps may also provide the capability to save the modified version with the changes incorporated. For example, Photo Editor

  • Hello, i have my iPhoto library on my macbook air. how can i duplicate this library on my new iMac?

    hello,
    i have my iphoto library on my macbook air. how can i duplicate this library on my new imac?
    thanks

    OS X: How to migrate data from another Mac using Mavericks

  • How can I convert a layer into a smart object with Adobe Photoshop Elements 10?

    How can I convert a layer into a smart object with Adobe Photoshop Elements 10?

    That feature is only in PS. Elements as you buy it has only limited support for smart objects. If you use File>Place to add something to your image it will come in as a smart object (within the limits to which PSE understands smart layers). However, if you know someone who can write an action for you in PS you can install it in PSE, or you could look into something like elements+ from simplephotoshop.com.

  • I want to upgrade my account to include illustrator but do not want to pay full price for both photoshop and illustrator.  How can I accomplish this?

    I want to upgrade my account to include illustrator but do not want to pay full price for both photoshop and illustrator.  How can I accomplish this?

    Photography plan is $9.99 and any added single subscription is $19.99
    Cloud Plans https://creative.adobe.com/plans

  • I have installed Illustrator thru Cloud and then un-install the Illustrator. How can I re-install it

    I have installed Illustrator thru Cloud and then un-install the Illustrator. How can I re-install I?

    Quit the Creative Cloud application and relaunch it again. When the CC app gets launched it scans through the installed applications and updates it's "Apps" tab accordingly. After this you can install Illustrator from the APPS tab.
    ~Raghuveer

  • HT2486 When you want to add another person from same company, how can you duplicate and then modify the card already entered?

    When usinf Mac Address Book and you have entered the information for one contact from a company, how can you duplicate the card so you can add another person from same company?

    I'm afraid the LU suffix is a new one on me.
    As long as you have all of the content in your library then that remove and sync warning shouldn't cause any loss of data, but it shouldn't be happening every time. It may pay to take the following steps to reset the connection between the two,
    Backup device.
    Restore as a new device.
    Restore the backup made earlier.
    Again, this assumes all content on the device is in your library. If that isn't the case see Recover your iTunes library from your iPod or iOS device first.
    tt2

  • How do i take one layer with multiple selections...

    how do i take one layer with multiple selections and make those selections their own layer?

    Yes sir. It w was really hard to explain. It is discontiguous segments that are separated by transparent areas. And I want those non transparent areas to be on their own layer. I have a photo shop file that has a bunch of buttons on them and they are on a transparent background. It is one layer. I want to select all the buttons and put them on their own layers. I can do this manually by selecting a button and cmd Just to a new layer, but when I have 200 buttons it is a daunting task.
    Sent by MailWise<http://www.mail-wise.com/installation/4> – Your emails, with style.

  • How can I have two fields with the same name if it makes sense?

    Hello, folks :)
    I have a pretty hard time figuring out how I can have two text fields with the same binding name.
    The whole problem is that when I need two fields with the same binding name they are still differnent coz they have the same name but differnt indices.
    I should make a form filled at runtime by merging a pdf form file and an fdf file data file. And I have no choice to do it differently. And my form file needs some data like customerName, companyName twice in one form. But there's only one possible buinding name indexed zero.
    How can I create a field with absolutely the same name or is it just impossible due to possible name conflicts? And is there a workaround to this problem? I just need one piece of data repeated in different places.
    Thanks for your replies :)
    P.S. if u think that the problem is not clear enough let me know. I'll supply you with more details. But the general process can not be changed.
    One pdf should be mergred with an fdf with as the result of their merge a new filled and flattened form. I have no control over fdfs their are generated by Oracle and I can not fill the form using XML files coz this process should be integrated in a working application.

    I just thought about a really ugly workaround with a server-side script adding values to fdf files but it's a bit of work and tests and personally i think it's a bad idea :-(

  • How can I create a solution with Livecycle

    I work for a high school and we have about 12 pdfs that we need parents to read/scroll through, then 10 (different) pages that we want them to print, complete and return to the school.  Finally, we want them to see a "Thank you, you have done all you have to do" type screen.  We want to make it as user friendly as possible so I was thinking...
    Reading pages, 1 at a time with next at bottom.
    Click next and it takes them on.  When they get to printing pages 1 print button prints all pages we need them to print. Click next, and it takes them to optional print pages.
    Click next and it says, thank you.
    How can I make this happen if I already have all the pdfs?
    Help please.
    John Dent
    [email protected]

    Thank you soo much.  A few questions?
    They weren't created in designer but could I just import all of them?
    How do "build the structure" for the naviagtion?
    Where/how do you add the script.
    Thanks again,
    John Dent
    Date: Fri, 30 Jul 2010 07:01:08 -0600
    From: [email protected]
    To: [email protected]
    Subject: How can I create a solution with Livecycle
    I assume that all of these PDFs were created in Designer. If so you can add any buttons that you want to appear on every page (Next, Previous) onto the Master page then there is script you can add to the buttons to actual move the pages (xfa.host.pageDown() and xfa.host.pageUp()). The Prin button can be added to the specific page and you can pass the page numbers that you want to print as a parameter to the print command. Lastly when you get to the last page and the click Complete you can display a messageBox with your Thank you message.
    Hope that helps
    Paul
    >

  • How can I create drop shadows with PSE10

    How can I create drop shadows with PSE10 & PE10?

    Layer styles let you quickly apply effects to an entire layer. In the Effects panel, you can view a variety of predefined layer styles and apply a style with just a click of the mouse.
    Three different layer styles applied to text 
    The boundaries of the effect are automatically updated when you edit that layer. For example, if you apply a drop shadow style to a text layer, the shadow changes automatically when you edit the text.
    Layer styles are cumulative, which means that you can create a complex effect by applying multiple styles to a layer. You can apply one style from each style library per layer. You can also change a layer’s style settings to adjust the final result.
    When you apply a style to a layer, a style icon appears to the right of the layer’s name in the Layers panel. Layer styles are linked to the layer contents. When you move or edit the contents of the layer, the effects are modified correspondingly.
    Once you choose Layer > Layer Style > Style Settings, you can edit the settings of a layer’s style or apply other style settings or attributes available in the dialog box.
    Lighting Angle Specifies the lighting angle at which the effect is applied to the layer.
    Drop Shadow
    Specifies the distance of a drop shadow from the layer’s content. You can also set the size and opacity with the sliders.
    Outer Glow Size Specifies the size of a glow that emanates from the outside edges of the layer’s content. You can also set the opacity with the slider.
    Inner Glow Size Specifies the size of a glow that emanates from the inside edges of the layer’s content. You can also set the opacity with the slider.
    Bevel Size Specifies the size of beveling along the inside edges of the layer’s content.
    Bevel Direction Specifies the direction of the bevel, either up or down.
    Stroke Size Specifies the size of the stroke.
    Stroke Opacity Specifies the opacity of the stroke.

Maybe you are looking for

  • EMac and Mac Mini?

    I have an eMac I recently upgraded to Leopard. I keep getting space warnings in iPhoto, which is what I use the computer most for (I produce a school yearbook on the eMac). Also my CD drive often takes 20 attempts to open. I would like to know if I s

  • Adding field with more than 255 characters to table VBAP

    Hi experts, i am with a requirment to add field model number to VBAP table. but the length of the field permitted is 255 char. basically model number comprises of all the characterstics fo material explained, so naturally its lenght will be long....s

  • CS5 Out of Memory - Context Sensitive Fill

    Trying a simple context sensitive fill and getting "could not fill because there is not enough ram". Have 8 gig ram installed.  Per Activity monitor CS5 is using 178.7 MB and there is 6.14 GB free.   Document size is 1.18 gig. Attached are relevant s

  • A scaled condition for all po-items

    Hello Gurus, we want to have a scaled condition for all po-items. Example: we have 1 PO with 2 PO-Items (same material). Each Po-Item has 1 piece. The condition scaled fort wo pieces. Any Ideas? Thank you! Peter

  • Muvo TX FM / N200 Size Compari

    Hello I currently have a Muvo 28 and like it quite a bit. However I would like to upgrade to a player with more memory. I am wondering how the size of the two units compare. I realize the N200 is a one piece design, but I do not want something that i