Getting the roundness of rectangle corners in a script

Hi, I know the roundness of rectangle corners can be set using these little drag circles, but I’d like to know where (or if) I can read/set the value in a Python script.

Other parameters like the width and height can be set quite easily, but I find no parameter to set the roundness.

Here’s a quick partial project export (requires 7.9.1) that has two spinners to set the width and height of the rounding arc. The relevant code that does the actual rounding off is on the shape as a custom method. Note that to duplicate this (or apply it to another shape) you must start with a rectangle that has some amount of rounded off corners; a purely rectangular shape is actually a different Java object that doesn’t have the rounding off code. The relevant code:

self.getShape().setRoundRect(self.relX, self.relY, self.relWidth, self.relHeight, width, height)

You’ll also want to fire a repaint() operation on the root container after you change the shape’s attributes; you can do this from the custom method, or from wherever you call it.
Rounding Rectangle.proj (8.1 KB)

Thanks for the answer, I didn’t know it was a native Java Rounded Rect, so I can use all methods listed here: … gle2D.html

That’s a great help.

Hmm, this did leave me with some other questions. I noticed there’s also a .getShape().getWidth() method.

But this neither matches the relWidth nor the width of the object.

I now have a template with a rounded rect in it, with the following data in designer:
[li]width: 920[/li]
[li]relWidth: 843[/li]
[li]getShape().getWidth(): 843[/li][/ul]

But when it’s scaled in the client, I get the following:
[li]width: 1302[/li]
[li]relWidth: 843[/li]
[li]getShape().getWidth(): 1193[/li][/ul]

So it appears the getShape().getWidth() scales with the screen, just as the regular width. But I don’t get the initial difference between the two in the designer.