http://imagej.273.s1.nabble.com/bug-in-rm-add-roi-or-in-Jython-running-rm-add-roi-tp5021021p5021033.html
Hi Albert and thank you for your reply.
Turned out that the method I needed was addRoi() , not add().
My bad -- I stared at the API docs and saw the wrong thing. And the js I
recorded did it right but again I missed it.
> Possibly because jython does not distinguish well equally named methods with the same number if arguments. No method dispatch by argument type. In this case, it is picking up the one you don't want.
>
> There are workarounds but they aren't pretty.
>
> Albert
>
>> On Jul 31, 2018, at 2:25 AM, Aryeh Weiss <
[hidden email]> wrote:
>>
>> I have a code snippet that creates a convex hull selection and tries to add it to the roimanager.
>>
>> IJ.run(segmentedImp, "Convex Hull", "")
>> convexHullRoi = segmentedImp.getRoi()
>> print convexHullRoi
>> rm.add(segmentedImp.getRoi())
>>
>> the print statement verifies that convexHullRoi is in fact an Roi:
>>
>> Roi[Polygon, x=772, y=955, width=1617, height=3299]
>>
>> yet, the rm.add(segmentedImp.getRoi()) statement throws an error
>>
>> rm.add(segmentedImp.getRoi())
>> TypeError: add(): 1st arg can't be coerced to java.awt.Component, java.awt.PopupMenu
>>
>> When I record the same sequence of operation as a javascript, I see the same command
>>
>> imp = IJ.getImage();
>> rm = RoiManager.getInstance();
>> if (rm==null) rm = new RoiManager();
>> rm.addRoi(imp.getRoi());
>>
>> The above js script works properly..
>>
>> Why do I get that typeError?
>>
>> --aryeh
>>
>> --
>> Aryeh Weiss
>> Faculty of Engineering
>> Bar Ilan University
>> Ramat Gan 52900 Israel
>>
>> Ph: 972-3-5317638
>> FAX: 972-3-7384051
>>
>> --
>> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html