Bug?: layers.add() is not working properly when invoked from menu (ID/CS6/Win7)

Hello Devs,
I am facing a mysterious issue with the layers.add() method.
I am trying to create n number of layers for my document. So I have decided to create a menu for this.
I have creatd two scripts
1. For creating menu & menu action,
2. Actual script that creates n number of layers.
When I run the script #2 direclty from ESTK it works fine.
Now when I try to invoke the same script from the Menu it is not working fine. Only the last layer is created.
Script 1: LayerPopupMenuAction
#target indesign
#targetengine createLayerset
var layerTemplateScript = File(File(getActiveScriptPath()).parent.fsName+"/IntializeTemplate.jsx");
var initTemplateHandler = {
    'beforeDisplay' : function(ev)
            ev.target.enabled = (app.documents.length>0);
    'onInvoke' : function()
            app.doScript(layerTemplateScript, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Initialize Script");
var layerMenuAction = app.scriptMenuActions.add("&Create Layer Set");
for(var init_ev in initTemplateHandler) {
    layerMenuAction.eventListeners.add(init_ev, initTemplateHandler[init_ev]);
var refMenuItem = app.menus.item("$ID/LayerPanelPopup");
refMenuItem.menuItems.add(layerMenuAction, LocationOptions.AFTER, refMenuItem.menuItems.item(2));
function getActiveScriptPath() {
    // This function returns the path to the active script, even when running from ESTK
    try {
        return app.activeScript;
    } catch(e) {
        return e.fileName;
Script 2: IntializeTemplate
#target indesign
if (app.documents.length == 0){
    alert("Please open a document and try again", "Document Error", true);
    exit();
var templateDoc = app.activeDocument;
var layerNameArray = ["Fixed_Static_Assets", "Absolute_User_Assets", "Relative_User_Assets"];
CreateLayers(layerNameArray);
alert("Initialization Successful");
//--------------------------------FUNCTIONS ARE DEFINED HERE--------------------------------
function CreateLayers(LayerNameList){
    var layerListLength = LayerNameList.length;
    var layerObject;
    for (var ln=0; ln<layerListLength; ln++){
        layerObject = templateDoc.layers.itemByName(LayerNameList[ln]);
        if (layerObject.isValid==false){
            layerObject = templateDoc.layers.add({name:LayerNameList[ln]});
            //$.writeln('Layer Creation: ' + layerObject.isValid + ' for '+layerObject.name);
    //Merger Default Layer with the bottom layer:
    var defaultLayer = templateDoc.layers.itemByName("Layer 1");
    if(defaultLayer.isValid==true){
        //$.writeln('Default is Valid and will be merged with top most layer');
        layerObject.merge([defaultLayer]);
Any help / guidance on this regard will be much helpful.
@Marijan Tompa [tomaxxi]: I googled for the solution and noticed that you have already worked on similar type of script. Please help me if you can.
Thanks
Green4ever

Hi Green4ever,
At a very first sight I'd suspect UndoModes.FAST_ENTIRE_SCRIPT which, as you may know, can deeply scramble script steps, especially when a try...catch is in use.
Try to replace FAST_ENTIRE_SCRIPT by ENTIRE_SCRIPT and tell us.
@+
Marc

Similar Messages

  • I've an iphone 4, its headset jack is not working properly, when i insert the earphone no sound is coming, but when i keep the earphone little out i can hear the sound but very low sound is coming out, I've never dropped my iphone please help...

    I've an iphone 4, its headset jack is not working properly, when i insert the earphone no sound is coming, but when i keep the earphone little out i can hear the sound but very low sound is coming out, I've never dropped my iphone please help...

    bunjamin wrote:
    There is now a new line in BBM that wasn't there before which covers the message that I am typing, so I can't actually see what I am typing.
    Hi bunjamin,
    just go to BlackBerry World, and update all your apps including BBM.
    bunjamin wrote:
    Every time I unlock my phone, my screen enlarges so I can't really see much on the hub/notification screen and it defaults to the hub which it didn't do before).
    you can turn off the magnifying glass :
    device settings >> accessibility >> magnify mode >> OFF
    you can deactivate the "reset to Hub view" :
    hub >> overflow (bottom right button) >> Settings >> Display and actions >> Return to Default View When Idle >> OFF
    bunjamin wrote:
    my ringtone is much softer than it was previously
    yes, BlackBerry has acknowledged this bug in this article from the public knowledge base:
    KB36755 After upgrading BlackBerry 10 OS to version 10.3.1 the volume for notifications is noticed to be significantly lower than in the previous version
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • My Ipod touch does not work properly.When i charge it,it only works for 5 min.n gets discharge.I showed it to the apple store in banglore n the person told me its fine n It is working properly.Bt its not working properly.Can someone help

    My Ipod touch does not work properly.When i charge it,it only works for 5 min.n gets discharge.I showed it to the apple store in banglore n the person told me its fine n It is working properly.Bt its not working properly.Can someone help

    If after you charge it for about three hours and it only last about five minutes the battery is probably dead or there could be another hardware problem.  I would go back to the Apple store and ask them specifically how can it be OK if the fully charged battery only lasts five minutes.

  • Clip inspector in imovie not working properly - when I select a picture - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and in a clip the audio adjustment only shows a speaker? help

    Clip inspector in imovie not working properly - when I select a picture (in project library) - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and when I select a movie clip and then click on audio adjustments the audio adjustment appears as a speaker icon and I don't know how to get to the various audio options? It was working fine one minute and then I seemed to lose the functionality. Also editing a photo in a photo or getting rid of ken burns effect etc does not seem to work. help

    Can anyone shed any light on this as I am having the same problem? One minute it works fine, the next you get the error message above.
    Many thanks.

  • Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Thanks for that information!
    I'm sure I will be calling AppleCare, but the problem is, they charge for the phone calls don't they? Because I don't have money to be spending to be on the phone with a support service.
    In other things, it seemed like the only time my MacBook was working was when I had Snow Leopard without the 10.6.8 update download that was supposed to be done to prepare for OS X Lion.
    When I look at the information of my HD it says that I have 10.6.8 but that was the install that it claimed to have failed and caused me to restart resulting in all of the repeated problems.
    Also, because my computer is currently down, and I've lost all files how would that effect the use of my iPhone? Because if it doesn't get fixed by the time OS 5 is released, how would I be able to upgrade?!

  • My macbook pro is not working properly , when is turned on after then show apple logo and continue show this or nothing.

    my macbook pro is not working properly , when is turned on after then show apple logo and continue show this or nothing

    Gray, Blue or White screen at boot, w/spinner/progress bar

  • Swf is not working properly when upload to server

    I develop 1.swf which is having 3 buttons each one having
    anather .swf to call 2.swf, 3.swf respectively.
    This application is running perfectly on my PC, but
    While uploading the swf to server the 2.swf and 3.swf is
    not running. Can any one tell how to recover from this kind
    of problem.

    justbipin wrote:
    > basically my code working perfectly,
    > but its not working properly when upload to server
    > can anybody having any ref. or link to solve this
    issues.
    why is that we insist on seeing the source file ?
    There is no one way of doing things in flash and no one can
    help
    you based on "does not work description".
    This is way to broad of a subject to even try to guess.
    Same as asking "my car does not work, what's up with
    that"....
    Please upload the problematic file and provide url for us to
    check.
    Otherwise you need to try to troubleshoot it yourself as we
    can't
    guess from here what possibly is wrong with that file.
    Regards
    Urami
    Happy New Year guys - all the best there is in the 2006 :)
    <urami>
    http://www.Flashfugitive.com
    </urami>
    <web junk free>
    http://www.firefox.com
    </web junk free>

  • TS1630 My Iphone 4s reciever is not working properly, when i call someone from my iphone 4s.  can any one help me how to solve this problem?

    My Iphone 4s reciever is not working properly, when i call someone from my iphone 4s.  can any one help me how to solve this problem?

    You might like to define "not working properly".

  • Application does not work properly when I press a CommanButton

    Hi all, I am having a problem with weblogic 10.3.5.
    It turns out that an application built with JDeveloper 11.1.5, I test it, and everything goes well in the JDeveloper integrated Weblogic.
    But when deploy in a standalone weblogic 10.3.5 server, the application does not work properly when I press a CommanButton to go to another page search (the property "action" is set correctly) , but nothing happens, stays in the same home page. Similarly when a commanButton link to run a task-flow, It do not work , however in the JDeveloper integrated Weblogic it runs correctly.
    How I can solve these problems?
    Thanks.

    Thanks Frank for help us, but when I writing this comment we are doing at home. So, we going to test the page in a stand alone weblogic server 10.3.5. We wrote the URL as :
    " http://<our ip>:7001/myApp/faces/index.jspx "
    this application contains a report desing and compiled with iReport 4.5.1 ( last version in the moment ), we can see the report when I press a commanButton without any problem.
    But now, we need try your suggestions in the office, and give you more information about it . Thanks for the moment.
    In the Afternoon we gonna give you more information about it .

  • Flip Card Animation is not working properly when Button's PointOver State remain Activated.

     I am facing problems with flip car animation which is not working properly when its mouse point over state remains activated but it works perfect when its tapped two times and instantly change pointer position. Kindly Help me out as soon as possible.
    Code is here:
    Xaml:
    <Image Name="imgCapital" RenderTransformOrigin=".5,.5" Tag="1" Tapped="imgCapital_Tapped">
    <Image.Projection>
    <PlaneProjection RotationY="0"/>
    </Image.Projection>
    </Image>
    <Image Name="imgSmall" RenderTransformOrigin=".5,.5" Tag="2" Opacity="1" Tapped="imgSmall_Tapped">
    <Image.Projection>
    <PlaneProjection RotationY="-90"/>
    </Image.Projection>
    </Image>
    Storyboard:
    <Storyboard x:Name="FlipOpen">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imgCapital">
    <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="90"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imgSmall">
    <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="-90"/>
    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>
    <Storyboard x:Name="FlipClose">
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imgCapital">
    <SplineDoubleKeyFrame KeyTime="0:0:0.4" Value="90"/>
    <SplineDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
    </DoubleAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="imgSmall">
    <SplineDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
    <SplineDoubleKeyFrame KeyTime="0:0:0.4" Value="-90"/>
    </DoubleAnimationUsingKeyFrames>
    </Storyboard>

    Actually i simply want flip card animation which is not working here in my code. When i tapped button to invoke animation its behavior not exactly flipping.  Its one side work properly but other collapsed suddenly not rotate if i keep mouse right at
    the button, but if i change mouse pointer at that very time after tapping it works properly. Mouse Pointer Over mean screen points where i tapped.
    Triggered Function is here:
      private void btnChangCase_Tapped(object sender, TappedRoutedEventArgs e)
                if(isCaseChanged==false)
                    isCaseChanged = true;
                    FlipOpen.Begin();
                else if(isCaseChanged==true)
                    isCaseChanged = false;
                    FlipClose.Begin();

  • I had photoshop elements 8 installed on my previous computer and it did not work properly when it came to sizing  photos for a website I was adding to.  I now have a new computer which runs windows 7.  Is it worth installing it again on my new computer?

    I had photoshop elements 8 installed on my previous computer and it did not work properly when it came to sizing  photos for a website I was adding to.  I now have a new computer which runs windows 7.  Is it worth installing photoshop elements 8 again on my new computer or will it be a waste of time?

    I have PSEv.8 on my computer running WINDOWS 7. It works perfectly..
    Perhaps you need help with saving files for web use.. Will be pleased to assist you when you get everything set up.

  • Image display control scrolling does not work properly when zoomed in

    I am using a ROI on an image in the image display control. When zooming into the image to fine-adjust the positioning of the ROI, the image scrolling does not work properly. As far as I understand, the image should scroll automatically when the ROI is leaving the visible area. However, the scrolling behaviour seems to depend on the origin of the Labview panel, not the origin of the image display control, which might require to move the ROI way out of the visible area before the scrolling takes place. In other words: the coordinate system of the image display control is shifted with respect to the true visible image area, depending on where you place it on the front panel. As a consequence, when clicking on a ROI which is in the visible area, but is outside of what Labview thinks is the visible area, it might immediately jump to the left border of the image, making the positioning of the ROI really difficult.
    Has anyone noticed this behaviour, and what would be a reliable solution to avoid this? 
    Dirk

    Hello,
    no, I am not talking about the tools palette. Just place an image control with some image in it on a new VI front panel. Then, use the rectangle from the tools and select a ROI in the image. If you zoom in (using the magnification glass), and then grab the ROI and move it around, the image scroll with the ROI. So far, so good. If you now place the image control elsewhere on the panel, or add new control above it, resize the panel, etc. , this scrolling when moving the ROI will not work correctly if the origin (0,0) of the panel is far away from the image control.
    I have attached a VI for simplicity (although there is hardly any code in it).
    If you make a ROI and try to move it down, you will notice that scrolling starts if you move the mouse out to about 10cms below the image (depens on your screen, of course). After that, if you click on the ROI, the scroll bars and ROI might jump up to the upper end of the image. Imagine how annoying this is if you try to finely adjust the ROI position. 
    I think it is a bug in the implementation of the image display control.
    Thanks,
    Dirk
    Attachments:
    scrolling.vi ‏818 KB

  • Subvi does not work properly when called inside a vi

    Hello Every body
    thanks for your help. i am using a sub vi for sine signal generation. as a vi it works fine. but when i called this subvi inside another VI it gives some problems. for example timer indicator works properly.it reinitializes as well in the sub vi, but in the main VI it does not work properly. means does not count the time.in the sub vi on the fly i can change the values of frequency and amplitude in real time, but when i use as sub vi, it does not reponse as i change the values in the control arrays.similarly pause and continue works properly in the sub vi, but once again in the main VI, it does not work properly.graph indicator also work properly in the sub vi. but here once again it does not work properly in the main VI.the pause resume indicator also does not blink, when it is continue. in the subvi it blinks very well.generally why the sub vi does not work properly inside the VI?i am sending my VI and sub vis.
    any tips would be highly appreciated.
    thanks
    Regards
    Attachments:
    vi.zip ‏87 KB

    I just want to add some more details to Dan's answer. The subVI is acting exactly like you've coded it. The mistake is in understanding how subVIs work. When you call a subVI (or a function in any other language), you pass some parameters to it, the subVI does it's thing and returns values. the subVI does not accept new parameters from the calling VI until it returns to the caller and the caller runs the subVI again. In your case, you have a subVI with a while loop. You have some front panel control wired to the subVI's stop terminal. When first called, the value is false. So the subVI will keep running until the subVI's stop button becomes true but you cannot change it from main until the subVI finishes and returns so the subVI will never stop. As Dan says, the solution is pass references of front panel controls to the subVI and have the subVI monitor those references for changes and to update references to indicators on Main. You subVI does not need any front panel controls or indicators of it's own.

  • Add-ons not working properly

    Recently (last 4-5 days my add-ons stopped working properly. Example: Tab Mix Plus shows as installed, but when any options I select do not affect tab behavior; Lastpass icon not showing up in the Add-on bar as it did previously; Newsfox icon doesn't appear in Toolbar as it did. Using Firefox 26.0 on Windows 8 on Dell Laptop.

    I've been having problems with my add-ons. Ad Block Plus will often hang Firefox and drive the CPU to 100%. I've reset Firefox and installed ABP, but still have the problem. My other extension have also stopped working. Any new extensions will appear to added on to Firefox, but they also don't work. I've followed all on-line trouble shooting options.

  • Satellite Pro U200: VGA output not working properly when AC adapter was connected

    Hi,
    I have a problem with vga output. When I'm working on battery and connect my notebook to external monitor it's ok, but when I connect AC adaptor then start waving also bluetooth and wlan does not work properly. In other case when I remove battery from notebook and connect AC adaptor it works properly.
    thanks in advance

    As long as you use a CRT you should set the refresh rate new, at least 85Hz. Standard is 60Hz as far as I know, and that hurts in your eyes.
    The wireless lan behaviour is quite normal as long as your not right next to the access point. On battery power the wireless lan card reduces its energy consumption thus the connection will be poor if you dont have a perfect signal. You can turn this off in the iNTEL Pro/SET wireless software, where you can configure the adaptor. Try to change the powersafe mode to manual and full power, this should solve your problem.

Maybe you are looking for

  • Can a video clip lose quality with ,multiple rerendering???

    I have a question, can rerender a video file, say I rendered and found I forgot to add chapter markers to sequence, rendered it to a Quicktime DV clip, I deleted all render files after export. Now all I have is the DV clip that needs to have chapter

  • How to keep Motion created titles looking sharp on final DVD?

    Hello again... I'm having trouble keeping my motion created titles looking sharp on the final DVDSP project. Im exporting a title sequence out of motion into fcp and then exporting the full project via compressor for burn in DVDSP. I'm familiar with

  • ODI Control Mechanism

    I need to design a control mechanism for ODI(Sunopsis) if Any one design it for their client such document is highly appreciated. I need following steps to include in the control mechanism 1.Organize Workflow 2.Restart strategy for Scenario 3.Log man

  • Using non-HP ink cartridges

    I have a Photosmart C6180 that uses HP 02 cartridges - black and five colors.  My local Walgreen's has a cartridge refill program.  I have always used HP cartridges, but what would I give up if I went the non-HP route?  Is the ink status gauge about

  • Too many blank page

    Hi All, I created a report that consists of only a crosstab. When I check the report in Preview mode, I see lots of blank page.. Actual report is 1 or 2 pages, but in the navigation toolbar, i see about 700 pages! Why it is like that and how can I re