Login  Register

Re: macro problem

Posted by Braekevelt Martin on Jan 09, 2019; 9:20am
URL: http://imagej.273.s1.nabble.com/macro-problem-tp5021600p5021614.html

Dear Michael,

Thank you very much !
this icon is exactly what i wanted, so now the startup is perfect.
I have seen you have changed something in the code also, but this gives an error while running the macro :

Undefined variable in line 51: setResult ( "Count" , row , <count> ) ;

Kindest regards,
Martin.


-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Michael Schmid
Sent: Tuesday, January 8, 2019 6:25 PM
To: [hidden email]
Subject: Re: macro problem

Hi Martin,

strange, I get a colorful icon with the macro from your StartupMacros.
It seems  that you have used the macro
   https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fimagej.nih.gov%2Fij%2Fmacros%2Ftools%2FImage_To_Tool_Icon.txt&amp;data=01%7C01%7Cmartin.braekevelt%40bekaert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a60214173f4df0c8%7C1&amp;sdata=6v3xnDpOQDEmeKlUNnJRC3ygZzXjaUAAAFYQp5azgYA%3D&amp;reserved=0
and selected the first red color as transparent, so some red pixels of your icon.tif file were missing in the icon. If I convert your icon.tif image without transparency, I get an even longer String:


macro "Volume fraction Action Tool -
Cf00D00D05D06D09D0aD1bD1fD22D24D2aD2eD2fD37D3cD3dD42D43D46D49D4eD55D59D5aD5cD5eD5fD61D62D68D72D75D7fD80D83D84D86D88D8cD8eD8fD90D92D98D9cD9fDa1Da2Da3DabDb8Db9DbbDc6Dc7Dc8DcbDccDd8DdaDdbDdeDe2De3De9DebDf1Df3Df5Df7Df9DfeC3f0D34D36D45D94DacDf0C0f0D02D04D11D18D25D26D27D28D30D31D41D64D6dD78D87D8dDc2Dc9DceDe1DffCff0D01D08D0bD0cD0dD0eD10D12D14D15D16D17D19D1aD1dD21D23D2bD2cD32D39D3aD3bD3eD3fD44D47D4aD4cD4dD50D51D52D53D54D56D58D5bD63D66D67D69D6aD6eD6fD71D73D74D76D79D7cD7eD82D89D91D93D96D97D99D9aD9dDa0Da8DadDaeDafDb0Db1Db2Db3Db5Db6DbaDbcDbdDbeDc0Dc1Dc4DcaDcdDd0Dd1Dd2Dd3Dd4Dd5DdcDddDdfDe0De4De5De6De7De8DedDeeDefDf2Df4Df6Df8DfaDfbDfdCcf0D35D38D48D4bD5dD65D7aDa4DcfCf90D03D07D0fD1cD1eD20D6cD7bD7dD81D85D8bD95D9eDa5Da6Da7DaaDb4Db7DbfDc5Dd6Dd7Dd9DeaDecDfcC7f0D2dD40D60D6bD77Cf20D13D29D33D4fD57D70D8aD9bDa9Dc3"{

Note that all of this must be in one line.

Michael
________________________________________________________________
On 08.01.19 12:31, Braekevelt Martin wrote:

> Sorry forget the StartupMacros.txt file
>
> // "StartupMacros"
> // The macros and tools in this file ("StartupMacros.txt") are //
> automatically installed in the Plugins>Macros submenu and // in the
> toolbar when ImageJ starts up.
>
> // The "AutoRun" macro has been replaced by the Edit>Options>Startup command.
>
>    macro "Command Finder Built-in Tool" {}
>    macro "Developer Menu Built-in Tool" {}
>    macro "Brush Built-in Tool" {}
>    macro "Flood Filler Built-in Tool" {}
>    macro "Arrow Built-in Tool" {}
>
>    var pmCmds = newMenu("Popup Menu",
>         newArray("Help...", "Rename...", "Duplicate...", "Original Scale",
>         "Paste Control...", "-", "Record...", "Capture Screen ", "Monitor Memory...",
>         "List Commands...", "Control Panel...", "Startup Macros...",
> "Search..."));
>
>    macro "Popup Menu" {
>        cmd = getArgument();
>        if (cmd=="Help...")
>             showMessage("About Popup Menu",
>                 "To customize this menu, edit the line that starts with\n\"var pmCmds\" in ImageJ/macros/StartupMacros.txt.");
>        else
>            run(cmd);
>    }
>
>   macro "-" {} //menu divider
>
>   macro "Volume fraction Action Tool -
> C3f0D34D36D45D94DacDf0C0f0D02D04D11D18D25D26D27D28D30D31D41D64D6dD78D87D8dDc2Dc9DceDe1DffCff0D01D08D0bD0cD0dD0eD10D12D14D15D16D17D19D1aD1dD21D23D2bD2cD32D39D3aD3bD3eD3fD44D47D4aD4cD4dD50D51D52D53D54D56D58D5bD63D66D67D69D6aD6eD6fD71D73D74D76D79D7cD7eD82D89D91D93D96D97D99D9aD9dDa0Da8DadDaeDafDb0Db1Db2Db3Db5Db6DbaDbcDbdDbeDc0Dc1Dc4DcaDcdDd0Dd1Dd2Dd3Dd4Dd5DdcDddDdfDe0De4De5De6De7De8DedDeeDefDf2Df4Df6Df8DfaDfbDfdCcf0D35D38D48D4bD5dD65D7aDa4DcfCf90D03D07D0fD1cD1eD20D6cD7bD7dD81D85D8bD95D9eDa5Da6Da7DaaDb4Db7DbfDc5Dd6Dd7Dd9DeaDecDfcC7f0D2dD40D60D6bD77Cf20D13D29D33D4fD57D70D8aD9bDa9Dc3"{
>      w = 4096;
>      h = 2160;
>      dir = getDirectory("Choose Source Directory ");
>      list = getFileList(dir);
>      for (i=0; i<list.length; i++) {
>         showProgress(i+1, list.length);
>         open(dir+list[i]);
>         run("Canvas Size...", "width=&w height=&h position=Center zero");
>         run("Maximize");
>         setLocation(0,0);
>         run("Unsharp Mask...", "radius=1 mask=0.60");
>         run("Grid...", "grid=Crosses area=85700 color=green bold center");
>         run("Set... ", "zoom=50");
>         setTool("multipoint");
>         run("Point Tool...", "type=Dot color=Red size=[Extra Large] label show counter=0");
>         waitForUser("Your Action Required", "Double click when center point of cross is inside,\n one click when on border or when have doubt.\n Then press OK");
>         if (selectionType() == -1) { // no selection count = 0;} else {getSelectionCoordinates(xpoints, ypoints); count = xpoints.length;}
>         row = nResults;
>         setResult("Label", row, getTitle());
>         setResult("Count", row, count);
>        close();
>      }
>      path = "C:/Users/Martin.Braekevelt/Desktop/Results.xls"
>      saveAs("Results", path);
> }
>   macro "About Startup Macros..." {
>        path = getDirectory("macros")+"About Startup Macros";
>        if (!File.exists(path))
>            exit("\"About Startup Macros\" not found in ImageJ/macros/.");
>        open(path);
>    }
>
>    // This example macro demonstrates how to create a
>    // custom command with a keyboard shortcut.
>    macro "Save As JPEG... [j]" {
>       quality = call("ij.plugin.JpegWriter.getQuality");
>       quality = getNumber("JPEG quality (0-100):", quality);
>       run("Input/Output...", "jpeg="+quality);
>       saveAs("Jpeg");
>    }
>
>
>
>
>
> -----Original Message-----
> From: ImageJ Interest Group <[hidden email]> On Behalf Of
> Braekevelt Martin
> Sent: Tuesday, January 8, 2019 12:19 PM
> To: [hidden email]
> Subject: Re: macro problem
>
> This message was sent from outside Bekaert with a Bekaert email address. It has been marked as potential email spoofing. Please do not click links or open attachments unless you recognize the source of this email and know the content is safe.
>
> Sorry to bother you again,
>
> I have downloaded the latest version of ImageJ instead of the Fiji version and copied paste like you have done for me Michael.
>
> I included the new StartupMacros.txt file.
> The position of the icon is where I wanted it, but I don't see the icon I constructed (the very long code), the icon should look like this (see attachment).
> All I get is a blank icon.
> The name I change is correct however  (Volume fraction) When I click on the icon I get an error (it says a { is expected at line 31),when I check the code however I think the correct of open close {} is there,...
> Can you please check what is wrong with the icon and why the macro is not running ?
> Thanks in advance,
> Martin
>
> -----Original Message-----
> From: ImageJ Interest Group <[hidden email]> On Behalf Of Michael
> Schmid
> Sent: Tuesday, January 8, 2019 10:23 AM
> To: [hidden email]
> Subject: Re: macro problem
>
> Hi Martin,
>
> sorry, I have plain ImageJ, not Fiji; I can't say whether Fiji uses other files for startup. With plain ImageJ, it works when I put it into my StartupMacros.txt. You might do some other changes in your StartupMacros.txt and see whether Fiji does these changes, otherwise it reads a different file.
> You might have a look, e.g., whether "StartupMacros.ijm" or "StartupMacros.fiji.ijm" exist (and are in use), instead of "StartupMacros.txt".
>
> Also make sure that you have no additional line breaks introduced by the mailer, e.g. the first line should include the long string with the code for the icon (a Strings constant must be given in one line).
>
>
> Michael
> ________________________________________________________________
> On 08.01.19 09:03, Braekevelt Martin wrote:
>> Dear Michael,
>>
>> I have done as you mentioned, tried 2 times to copy/paste in the macros folder in the StartupMacros.Fiji.ijm file, at 2 different positions in that file, restarted Fiji and even my computer but the macro is not there, neither the icon. Do I need to copy/paste the macro in another location ?
>>
>> Last obstacle I think ?
>>
>> Kindest regards,
>> Martin
>>
>> -----Original Message-----
>> From: ImageJ Interest Group <[hidden email]> On Behalf Of
>> Michael Schmid
>> Sent: Monday, January 7, 2019 5:11 PM
>> To: [hidden email]
>> Subject: Re: macro problem
>>
>> Hi Martin,
>>
>> This is not a macro tool that has to be executed when the user clicks somewhere on the image (as, e.g., the drawing tools) but simply by clicking the tool icon. So it is an "Action Tool", and you need to use this keyword in the macro name.
>>
>> Then just put the macro code between the curly braces and paste the whole thing into the StartupMacros.txt.
>>
>>
>> macro "myTool Action Tool -
> C3f0D34D36D45D94DacDf0C0f0D02D04D11D18D25D26D27D28D30D31D41D64D6dD78D8
> 7D8dDc2Dc9DceDe1DffCff0D01D08D0bD0cD0dD0eD10D12D14D15D16D17D19D1aD1dD2
> 1D23D2bD2cD32D39D3aD3bD3eD3fD44D47D4aD4cD4dD50D51D52D53D54D56D58D5bD63
> D66D67D69D6aD6eD6fD71D73D74D76D79D7cD7eD82D89D91D93D96D97D99D9aD9dDa0D
> a8DadDaeDafDb0Db1Db2Db3Db5Db6DbaDbcDbdDbeDc0Dc1Dc4DcaDcdDd0Dd1Dd2Dd3Dd
> 4Dd5DdcDddDdfDe0De4De5De6De7De8DedDeeDefDf2Df4Df6Df8DfaDfbDfdCcf0D35D3
> 8D48D4bD5dD65D7aDa4DcfCf90D03D07D0fD1cD1eD20D6cD7bD7dD81D85D8bD95D9eDa
> 5Da6Da7DaaDb4Db7DbfDc5Dd6Dd7Dd9DeaDecDfcC7f0D2dD40D60D6bD77Cf20D13D29D
> 33D4fD57D70D8aD9bDa9Dc3"{
>>       w = 4096;
>>       h = 2160;
>>       dir = getDirectory("Choose Source Directory ");
>>       list = getFileList(dir);
>>       for (i=0; i<list.length; i++) {
>>          showProgress(i+1, list.length);
>>          open(dir+list[i]);
>>          run("Canvas Size...", "width=&w height=&h position=Center zero");
>>          run("Maximize");
>>          setLocation(0,0);
>>          run("Unsharp Mask...", "radius=1 mask=0.60");
>>                    run("Grid...", "grid=Crosses area=85700 color=green bold center");
>>          run("Set... ", "zoom=50");
>>          setTool("multipoint");
>>          run("Point Tool...", "type=Dot color=Red size=[Extra Large] label show counter=0");
>>          waitForUser("Your Action Required", "Double click when center point of cross is inside,\n one click when on border or when have doubt.\n Then press OK");
>>          if (selectionType() == -1) { // no selection
>>             count = 0;
>>          } else {
>>             getSelectionCoordinates(xpoints, ypoints);
>>             count = xpoints.length;
>>          }
>>          row = nResults;
>>          setResult("Label", row, getTitle());
>>          setResult("Count", row, count);
>>         close();
>>       }
>>       path = "C:/Users/Martin.Braekevelt/Desktop/Results.xls"
>>       saveAs("Results", path);
>> }
>>
>>
>> Now it is time for you to learn a bit more on macro programming!
>>      https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fimagej.nih.gov%2Fij%2Fdocs%2Fguide%2F146-14.html&amp;data=01%7C01%7Cmartin.braekevelt%40bekaert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a60214173f4df0c8%7C1&amp;sdata=KZFfXQtmddEgANPszgfYY5BH1xM9j%2FAKdtQ1t5%2FuW40%3D&amp;reserved=0
>>      
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fim
>> agej.nih.gov%2Fij%2Fdeveloper%2Fmacro%2Fmacros.html&amp;data=01%7C01%
>> 7Cmartin.braekevelt%40bekaert.com%7C8b7090b1caf04546451d08d6758e4e2b%
>> 7Cd9e53fd413d74ca7a60214173f4df0c8%7C1&amp;sdata=C0Bt8e1%2BDkphlsL0e%
>> 2FfLqgP8X5CDGgRPJ5aSOSpyqkE%3D&amp;reserved=0
>>      
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fim
>> a
>> gej.nih.gov%2Fij%2Fdeveloper%2Fmacro%2Ffunctions.html&amp;data=01%7C0
>> 1
>> %7Cmartin.braekevelt%40bekaert.com%7C295840124e07420b292008d6755b4cf9
>> %
>> 7Cd9e53fd413d74ca7a60214173f4df0c8%7C1&amp;sdata=SPRv1HSqaQi4bfRFveq1
>> e
>> 3IyurJuWTmvC7sfrrCCMtc%3D&amp;reserved=0
>>
>>
>> Michael
>
> --
> ImageJ mailing list:
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag
> ej.nih.gov%2Fij%2Flist.html&amp;data=01%7C01%7Cmartin.braekevelt%40bek
> aert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a6021417
> 3f4df0c8%7C1&amp;sdata=2pb15ERsCuLIdzH9YTJ8KgprCt6T11XIi7PDZbYLxbQ%3D&
> amp;reserved=0
>
> --
> ImageJ mailing list:
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag
> ej.nih.gov%2Fij%2Flist.html&amp;data=01%7C01%7Cmartin.braekevelt%40bek
> aert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a6021417
> 3f4df0c8%7C1&amp;sdata=2pb15ERsCuLIdzH9YTJ8KgprCt6T11XIi7PDZbYLxbQ%3D&
> amp;reserved=0
>
> --
> ImageJ mailing list:
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimag
> ej.nih.gov%2Fij%2Flist.html&amp;data=01%7C01%7Cmartin.braekevelt%40bek
> aert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a6021417
> 3f4df0c8%7C1&amp;sdata=2pb15ERsCuLIdzH9YTJ8KgprCt6T11XIi7PDZbYLxbQ%3D&
> amp;reserved=0
>

--
ImageJ mailing list: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=01%7C01%7Cmartin.braekevelt%40bekaert.com%7C8b7090b1caf04546451d08d6758e4e2b%7Cd9e53fd413d74ca7a60214173f4df0c8%7C1&amp;sdata=2pb15ERsCuLIdzH9YTJ8KgprCt6T11XIi7PDZbYLxbQ%3D&amp;reserved=0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html