Why is the circle not drawn

import rhinoscriptsyntax as rs
rs.Command("_Circle " + str(0) + “_Enter” + str(20) + “_Enter” )
Simple question. Why is the circle not drawn?

I don’t know. Maybe you need a point as the first parameter?
Why don’t you simply use rs.AddCircle((0,0,0) , 20), instead?

You cannot concate the string inside the brackets of rs.Command
If you first concatenate the string and then feed it to rs.Command it should work.

1 Like

This works fine:

rs.Command("_Circle 0 20")

Sure you can…

This also works (but I don’t know why you would do this):

origin=str(0)
dia=str(20)
rs.Command("_Circle "+ origin + " " + dia)

The best answer.

1 Like

This is just an example.

I always recommend using native rhinoscriptsyntax methods if possible, and in general it’s not more complicated than runing rs.Command()s and trying to figure out the correct macro.

There are some operations that do not have specific rhinoscriptsyntax methods and thus require using rs.Command(), notably importing and exporting files, but also things like creating a TextObject. Some of the command strings can be long and complicated, and need to have the various arguments in the correct syntax and order. In this case I find it best to use the Rhino built-in macro editor to set up the string first until you know it works, then transfer it to the script. I do recommend concatenating those kinds of strings first outside before feeding them to rs.Command(), it’s just much easier to understand and debug that way.

One other hint for getting rs.Command() macros working is to resist the temptation at first to cut command line reporting by using rs.Command(my_comm_string, False). If your script is not working, the command line reporting will be helpful in debugging where your command string is wrong. After running the script, press F2 to get the command history and you will see exactly at what point Rhino did not understand what was input (most likely an “unknown command” message).

Once you have your command string macro is working inside your script, then add the optional False argument in rs.Command() to cut the command line reporting - if you want.

2 Likes