Bug? : layers.add () does not work correctly when called from the menu (ID/CS6/Win7)
Hello Devs,
I am facing a mysterious problem with the layers.add () method.
I am trying to create n number of layers for my document. So I decided to create a menu for that.
I created two scripts
1. for creating menu & menu action.
2. real script that creates n number of layers.
When I run the script #2 of ESTK directly it works fine.
Now when I try to call the same script in the Menu it does work very well. 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 / advice on this topic will be useful.
@Marijan Tompa [tomaxxi]: I googled for the solution and I noticed that you have already worked on the same type of script. Please help me if you can.
Thank you
Green4ever
Hi Green4ever,
I think at a first sight, UndoModes.FAST_ENTIRE_SCRIPT , who, as you may know, can scramble deeply the script steps, especially when one ... try statement catch is used.
Try to replace FAST_ENTIRE_SCRIPT by ENTIRE_SCRIPT and tell us.
@+
Marc
Tags: InDesign
Similar Questions
-
Application does not work correctly when I press a CommanButton
Hi all, I'm having a problem with weblogic 10.3.5.
It turns out that an application created with JDeveloper 11.1.5, I have test and all is well in that the JDeveloper integrated Weblogic.
But when to deploy on a stand-alone 10.3.5 weblogic server, the application does not work correctly when I press a CommanButton to go to another search page (the 'action' property is properly set), but nothing happens, remains in the same home page. Similarly when a link of commanButton to run a workflow, it does not work, however in the integrated JDeveloper to Weblogic it works correctly.
How can I solve these problems?
Thank you.One thing you shouldn't do is add '.jspx' to your URL. This shows the page, but does not start the life cycle of faces that show not work button not working navigation.
Usehttp://
:7001/myApp/faces/index And it should work.
Timo
-
My CS4 does not work correctly. I have the download. I need to reinstall it.
My CS4 does not work correctly. I have the download. Should I delete everything and reinstall and use the provided SN? Will it work?
If you want to reinstall, do not delete anything. Use the uninstaller in your CS4 folder and if asked, select "delete preferences" then uninstall. When you have finished reinstalling, downloading and updates.
-
I am on iOS 9.2 and Game Center still does not work. When I open the app it freezes on a blank page. When I open the Game Center in the Middle it hangs just. For this reason, I can't back up my data on my games. Please Apple can solve this problem of iOS 9.2.
Hello Vaishnav,
Thank you for using communities of Apple Support.
I see that you are having problems with Game Center on your iPhone. I have a number of things for you to try.
First force quit Game Center.
- Press the Home button twice quickly. You will see small glimpses of your applications recently used.
- Swipe to the left to find the Game Center app to close.
- Swipe up on the preview of the Game Center to close.
If this does not work, then the next step would be a restoration. I recommend restore like new, without backup restore and everything first. If it works there, you can restore the backup.
Use iTunes to restore your iPhone, iPad or iPod to factory settings
Best regards.
-
to refine my question. The Lasso tool does not work. When I select the content aware lasso shrinks and nothing changes. Help please.
A simple reset will often be the case if a tool becomes awkward. Go to this link, then select the lasso tool:
-
You can visit the Web at www.conceptfizz.co.uk, office computer works great, but version phone does not charge full-screen, only on the left side. Thank you
It is no doubt loading the mobile version. Select all items on the page to verify that you haven't left anything on the right side of the page, or the areas encompassing the widgets have not expanded too far - this often happens when you move components.
David
-
Wireless Mouse 5000 does not work correctly when moved away from the transmitter.
I have the mouse as shown in the title with new batteries.Link: http://www.microsoft.com/hardware/en-us/p/wireless-mouse-5000/MGC-00017My installed OS Windows 7 x 64 SP1. A clean installed on the computer without additional software in the meantime.When I connect the transmitter (2.4 ghz v7.0 model 1423) the mouse to the computer, it identifies only, and the mouse works.In devices and printers, the transmitter is under indefinite and after installing IntelliPoint 8.2 64-bit for Windows 7, it remains the same.Sometimes the mouse does not react on the screen, as it got stuck and moving in parts rather than sequentially. Including the mouse buttons that do not meet at the moment.If I bring the mouse close to the transmitter, the problem goes away and it works fine.After the test, no relation to the load on the processor, the problem appears randomly.I tried to replace USB ports but no change, the problem goes away only if I put the mouse close to the transmitter.Original title: Wireless Mouse 5000Hello Tomer,.
Thanks for the reply.
You can check the following items and check if it helps to solve this problem:
The wireless keyboard or mouse may not respond and may start and stop at irregular intervals
Troubleshoot a wireless mouse that does not correctly
Troubleshoot the incidents of the response to the mouse or wireless keyboardIf the problem persists always, as mentioned above, contact Microsoft Hardware support for assistance. All material related to problems are treated by them.
Email us if you have any other issues related to Windows.
-
Match pattern does not work correctly when you are looking for a null character
I use the match pattern to retrieve a string NULL completed a response, I'm getting a device on a serial port. The VI is attached and here is a screenshot of the block diagram.
It works very well with the index value 0, 1, or 2. When index is 3, I get the result below.
Why model matching is not finding the null character?
Thank you!
I'm Datura, need to remove the cable from the shift control for the control of the match pattern.
DUH!
-
label printing does not work correctly. Printing in the wrong places
printer and printing labels shows only 1 inch on each label last in.
Hello
1. do you have drivers for Windows 7 installed?
2. is the application-specific question?
3. are you able to print correctly using different applications?
I suggest you to download the latest drivers from the manufacturer's Web site and check.
Software drivers &
Additionally, make sure that you have installed the latest version of the CD LabelPrint software:
http://software.Canon-Europe.com/software/0030999.asp
You can also contact the program support for assistance if the problem persists.
-
Tecra A9 - network does not work after wake up from the sleep/hibernation mode
I have TECRA A9 and it works fine, but I found that when computer portable GB extended standby/sleep mode and after the return to work on the laptop to the network not working not.
Keep it light, but there is no network and to solve it, I need to restart the laptop.Any help please.
Kind regards.
This is a known issue so take a look at this site:
http://APS2.toshiba-tro.de/KB0/TSB8902FC0000R01.htmUpdated the BIOS, and then it will work.
-
Headset does not work for phone calls on the iPhone 6 s with update of iOS 10
Is there a way to solve this problem
Go to settings > Bluetooth and turn Bluetooth off then turn it back on.
If this does not help, the pair of UN then re pair the headset > Set install and use third-party Bluetooth - Apple Support Accessories
-
Toshiba CANVIO 1 TB, its does not work correctly when I connected to my PC
Eevery time I connect my HARD drive to the computer, not finished loading files and gets stuck. I was recommended to replace the cable, but I did, and he still has the same error.
It's been a while since you posted this message in this forum.
Have you ever mange to get access to the HARD drive?In my opinion the question looks a bit like a HARD drive hardware problem.
I put t know if the data on that HARD disk is important to you, but if you have a backup of data, you can try to format the EXTERNAL HARD drive just to check if it would help to get the drive HARD working again. -
Tried to run the system restore, but it will not restore.
Hey AnnEdelstein,
Because you can't get the system restore to work, perform a clean boot on your Windows XP system. The guide to that is here. Which follow, and then try again to Outlook. If it works to the minimum, then boot in the boot, analyse the whole system with your Antivirus and other security you have.Also make sure you have the drivers for the keyboard. Search for the manufacturing of the keyboard, and they should have the drivers on their support site. I hope this has been helpful! -
WiFi falls trying to read videos HD of Apple TV 4 after the connection to Bluetooth speakers.
25Mbps of wifi speed. Router is placed very close to Apple TV box.
signal weakens and show, stuck between the two
Likely interference, try Ethernet connection
-
I have two main models I use, their use for just the month without problem on a mac, you have a PC and installed CC in Lightroom, but he has decided that she wants to be stupid. This product only when I move a model oriented portrait in a landscape oriented one or vice versa. Sometimes I can fix it by exchanging between many different models and more and all of a sudden he finds himself again and I'm good to go. I * could * close and reopen Lightroom but it mucks up to printing, the model goes back to normal, but the next draw will be missing a color completely. Its a big waste of ink when a set of my inks costs $500. I'm on a PC and have the latest installed version of LR. I have attached the screencaps. Some would like TO help on this issue.
To anyone who has this problem, Adobe fixed it for me. When and only when the model is displayed correctly (usually on start-up LR) then right-click on this model and choose "Update with current settings". As the models were created on my mac for a reason any PC did not want to make them work properly. They will be working always once start LR so this should be an opportunity for you to correct!
Maybe you are looking for
-
Photos transferred via USB use optimize the functionality for iCloud photo library?
Hello I recently transferred 1000 files to my mac via a flash drive. I want to have optimized photos and not actually be fully downloaded on my mac and I'm currently using iCloud photo library with optimization turned on. Does the work automatically?
-
How to send data from the client to the server using tcp
1. as I am new to watch I need help with sending data from client to server. I went through various examples of labview, but each of them also explains transfer of data to the client server. But I need help regardng send data from the server to the c
-
Order of execution with waveform of reading
I'm trying to find a way to control the order in which the sound files are played when Set up like that. It does not run them up and down as I thought it might. How can I control this order? Im sure that there is a better way to connect as well, I'm
-
My friends laptop resonance had some problems bad windows which culminated in him having to reinstall windows. I have an Edition Vista Home premium 64-bit SP1 CD, which is what he needs. We could get is the product key and what version of windows he
-
Replace all English win 10 French Win 7 Ultimate
If I buy a version in French of Windows 7 Ultimate, can I change it to English and then he move to only English Windows 10?