Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
If I accidentally click 'OK' before making a selection, it appears I would have to restart the macro because an area selection is required for the rest of the macro to run, resulting in the message "area selection required". This is inconvenient because I am working with folders containing 160 images, and the macro starts with the first file in the directory. Is there a way to prevent this from happening? Perhaps I can add something that will run waitForUser again if a selection is not made?
Here is the part of my macro I am referring to setTool("oval"); waitForUser("Select areas","Hold shift while drawing circle, then click 'OK'"); run("Crop"); setBackgroundColor(255, 255, 255); run("Clear Outside"); run("Measure"); Thank you! |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi Andrew,
You can enclose your wait command inside a while loop that checks for a region existing: while(regionType()<0){ waitForUser("Select Area"); } regionType() returns -1 if there's no region so you can't escape the loop without drawing one. Note that if there's a region on the image before this point then the wait command won't execute at all so you may need to put run("Select None"); beforehand Hope this helps, -Lachie ----- Original Message ----- From: "Andrew Sanchez" <[hidden email]> To: [hidden email] Sent: Friday, 3 July, 2015 7:48:48 AM Subject: Looping waitForUser if correct action not taken If I accidentally click 'OK' before making a selection, it appears I would have to restart the macro because an area selection is required for the rest of the macro to run, resulting in the message "area selection required". This is inconvenient because I am working with folders containing 160 images, and the macro starts with the first file in the directory. Is there a way to prevent this from happening? Perhaps I can add something that will run waitForUser again if a selection is not made? Here is the part of my macro I am referring to setTool("oval"); waitForUser("Select areas","Hold shift while drawing circle, then click 'OK'"); run("Crop"); setBackgroundColor(255, 255, 255); run("Clear Outside"); run("Measure"); Thank you! -- View this message in context: http://imagej.1557.x6.nabble.com/Looping-waitForUser-if-correct-action-not-taken-tp5013402.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html ______________________________________________________________________ The information in this email is confidential and intended solely for the addressee. You must not disclose, forward, print or use it without the permission of the sender. ______________________________________________________________________ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Hi Lachie,
Thanks for your response. Sounds great but I got the Macro Error "Undefined identifier": while(<regionType>()<0){ Any idea why? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
Andrew,
I think it should read selectionType(); instead. BTW, it is always a good idea to consult the ImageJ-docs, in this case the "Built-in Macro Functions" <http://rsb.info.nih.gov/ij/developer/macro/functions.html> HTH Herbie :::::::::::::::::::::::::::::::::::::::::::: Am 03.07.15 um 23:27 schrieb Andrew Sanchez: > Hi Lachie, > > Thanks for your response. > > Sounds great but I got the Macro Error "Undefined identifier": > while(<regionType>()<0){ > > Any idea why? -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Disable Popup Ads | Edit this page |