Scripting rhino commands


#1

When I create a macro using the macro editor, I can make multi-line macros, like this:
-options
modelingaids
nudge
step=1
enterend

But when I try to do the same in RhinoScript or PythonScript (is it called pythonscript?), I can’t do that. For instance, in RhinoScript, this doesn’t work:

Rhino.command “-options”
Rhino.command “modelingaides”
Rhino.command “nudge”
Rhino.command “step=1”
Rhino.command “enterend”

And in python, the same doesn’t work (rs.command ("-options") etc)

Instead, I have to make it all one line, like
Rhino.command “-options modelingaids nudge step=1 enterend”

But when I look at documentation for PythonScript, I read that I should break rhino commands into separate lines instead of a single long line:

Note, this function is designed to run one command and one command only.
Do not combine multiple Rhino commands into a single call to this method.
WRONG:
rs.Command("_Line _SelLast _Invert")
CORRECT:
rs.Command("_Line")
rs.Command("_SelLast")
rs.Command("_Invert")

So, is this a documentation error, bug, or am I just doing something wrong?

Basically, if I try to do the following in python (or rhinoscript,) rhino stops after running “-options”. Why?

def simpleFunction():
rs.Command ("-options")
rs.Command (“ModelingAids”)
rs.Command (“Nudge”)
rs.Command (“step=1”)
rs.Command (“enterend”)


#2

Hi @phcreates,

the helpfile is correct, what belongs to multiple commands should be in a seperate call to rs.Command(). Since you’re calling the _-Options command you can specify what belongs to this single command in a single line eg:

rs.Command("_-Options _ModelingAids _Nudge _Step=1 _EnterEnd", False)

Note that the second argument False after the command string avoids that your command is shown at the CommandLine.
_
c.


#3

Oh, I see - so anything nested within (for instance) “-options” is all part of one command? That makes sense.


#4

Yes.

_
c.


#5

Thanks