Python - rounded rectangle

Hi

I’m a new on python, so…
…to draw a rectangle i have to use “AddRectangle”
…and what to draw the rounded rectangle?

There is no rhinoscriptsyntax method for making rounded rectangles. So, probably the easiest way is to script the Rhino command with rs.Command(). A simple example:

import rhinoscriptsyntax as rs
origin="0,0,0"
length=str(25.0)
width=str(15.0)
rad=str(5.0)

rs.Command("_Rectangle _Rounded "+origin+" "+length+" "+width+" "+rad)

In the above case each data value is converted into a string and then concatenated into one command string to be passed into rs.Command()

A slightly more sophisticated way to do this would be to use the .format statement in Python to do all the string conversion for you:

import rhinoscriptsyntax as rs
origin=rs.GetPoint("First corner of rectangle")
length=rs.GetReal("Length")
width=rs.GetReal("Width")
rad=rs.GetReal("Corner radius")

rs.Command("_Rectangle _Rounded {} {} {} {}".format(origin,length,width,rad))

In both cases you should run the Rhino command first to see all the command line options and the order in which they need to be organized into the command string. If the Rhino command uses a dialog box, you will need to use the -dashed version of the command to bypass the dialog box.

HTH, --Mitch

Thank you so much,
the second one it’s just what i was looking for!