Rs.Command accepts arguments of which type?


I have just discovered the rs.Command() method.
I was wondering what kind type of arguments could be passed to it?
Point3d seems to work?

import rhinoscriptsyntax as rs

a = rs.GetPoint("take pt1")
b = rs.GetPoint("take pt2")
rs.Command("-Line " + str(a) + " " + str(b)+ " ")

print type(a)
print type(b)

But when I try passing a Guid:

import rhinoscriptsyntax as rs

c1 = rs.GetObject("take curve1")
c2 = rs.GetObject("take curve2")
rs.Command("-Fillet "+str(c1)+" "+str(c2)+" ")

print type(c1)
print type(c2)

I get a message: “Unknown command: 1ded1e11-3890-4d89-9b71-998f1d28febb”. For both c1 and c2.

Why is that? rs.Command does not work with Guids?

Thank you.


Well what you’re doing (it appears) is running a method that lets you pass Rhino a command macro, and no those don’t let you simply pass GUIDs, unless you add SelID (I think?) to your string to actually pick by ID.


Thank you for the reply Jim.
So this is how Selid needs to be added:

rs.Command("-Fillet " + "selid " + str(c1) + " " + "selid " + str(c2)+" ")

Where can I find a bit more information on what that selid actually is?


It’s just a selection command that allows you to enter an object ID (GUID) and if that ID is found in the document and the object is selectable, it will be selected. There’s not much more information than that…



Thank you Mitch
Does this mean that with rs.Command I could sort of simulate any Rhino command, even those that are not available among Rhinoscript methods?
For example there is no rs.AddArcBlend method.
But could I just “call” the ArcBlend command from Rhino using the rs.Command:

import rhinoscriptsyntax as rs

c1 = rs.GetObject("pick up the first curve",4)
c2 = rs.GetObject("pick up the second curve",4)
rs.Command("-ArcBlend " + "SelID " + str(c1) + " SelID " + str(c2) + " ")



Most but not all… There are some commands that rely on screen picks that cannot be easily scripted - if at all. For example AcrBlend relies on which end of the curve you pick on-screen. If you run your script as is, it will connect the two curve start points by default. You can work around this by using GetCurveObject, collecting where the pick points are and flipping the curves if necessary before calling rs.Command.

On the other hand there are some commands that can ONLY be scripted using rs.Command - notably Open, Save/As, Import and Export…



I just realized, I do not know how to does Fliping of the curve, works.
Tried something, but it does not work:

import rhinoscriptsyntax as rs
import math as m

c1 = rs.GetCurveObject("pick up the first curve",4)
c1_g = c1[0]   # curve1 Guid
c1_t = c1[4]   # curve1 parameter of the selected point
c1_dom = rs.CurveDomain(c1_g)
c1_dom = m.fabs(c1_dom[0])+m.fabs(c1_dom[1])
if (c1_dom - m.fabs(c1_t)) < (c1_dom/2):

c2 = rs.GetCurveObject("pick up the second curve",4)
c2_g = c2[0]   # curve2 Guid
c2_t = c2[4]   # curve2 parameter of the selected point
c2_dom = rs.CurveDomain(c2_g)
c2_dom = m.fabs(c2_dom[0])+m.fabs(c2_dom[1])
if (c2_dom - m.fabs(c2_t)) < (c2_dom/2):

rs.Command("-ArcBlend " + "SelID " + str(c1_g) + " SelID " + str(c2_g) + " ")



Your code seems to work here. You just need to add an _Enter at the end of the command string to complete the ArcBlend command.

rs.Command("-ArcBlend " + "SelID " + str(c1_g) + " SelID " + str(c2_g) + " _Enter")



Please take a look at this video:

It seems something is wrong with my domain+flipCurve conditional:

The script is not creating an Arc according to correct picked points


any help with this please?


Does the following work for you? --Mitch

import rhinoscriptsyntax as rs

def CheckFlipCrv(crv,param):
    dom = rs.CurveDomain(crv)
    if abs(dom[1]-param) < abs(param-dom[0]):

c1 = rs.GetCurveObject("pick the first curve near end to blend",4)

c2 = rs.GetCurveObject("pick the second curve near end to blend",4)

rs.Command("-ArcBlend " + "SelID " + str(c1[0]) + " SelID " + str(c2[0]) + " _Enter")


Works perfectly. Thank you.
Just this more:
What is the difference between " " and “_Enter” when used in rs.Command?


The " " makes the commands split. You can also do

 rs.Command("-ArcBlend SelID " + str(c1[0]) + " SelID " + str(c2[0]) + " _Enter") 

and you can add more commands in the rs.Command and split it with " ", the Enter mimics the command of pressing the Enter button.

Sometimes you have to press enter when you want to end a command of stop selecting. the _enter does the same to exit a menu or command.

You can try it if you got an object selected:

rs.Command("-_properties _object _name testname") 

You would still be in the menu at the end of the script. If you add _enter _enter (2 times because you have to exit 2 menus).

rs.Command("-_properties _object _name testname _enter _enter") 

This is how I would explain it :).


I would always use " _Enter" where you specifically want to simulate the user pressing the enter key to terminate the command.

As far as setting options within the command string, Rhino is somewhat inconsistent in this regard, sometimes you need to script options with an equals, as in "...value=n..." and sometimes you need to use a space as in "...value n...". Only way to know for sure is to test.



Not sure I understand.
Thank you both.