Scripts + interactive command line (REPL) in Rhino how?

Hi,

I’m just learning Rhino and really loving it. I’m a coding kind of person, so am writing Python scripts to do everything I need, with the occasional embedded macro when that seems easier.

The one thing I’m missing is an interactive command line where I could enter any valid python command and have Rhino execute it the way it does python scripts - that’s the fun of interpreted languages after all! Especially when in the middle of a debug, it would be great to execute arbitrary commands in that context, without having to [stop script/click OK/make the change/rerun the whole script] that I have to do now.

I want to execute exactly the code that will go into the script, not a macro - essentially looking for a Matlab-like REPL functionality where I can enter some code or for example select a couple of lines from my script file, say ‘evaluate’ and see the impact of evaluating just those lines immediately.

The best idea of how to get close to that that I could come up with would be automating Rhino from Matlab via the COM interface, so my scripts would actually be Matlab scripts. However that’s not exactly pretty.

Attaching a remote python debugger (from a python editor that supports an interactive command line) to Rhino would not help me here, as that can only step through the code that’s already running, not interpret new code - is that correct?

Really thankful for any suggestions,
Egor

There is a “TestInteractivePython” command in Rhino that was never really completed to a level that we felt was really useful. You’re welcome to play with it though if you want to give a REPL a try in Rhino.

1 Like

Thanks a lot!

From first minute of testing, it seems really fond of interpreting spaces as newlines, even in quoted strings, and also if I paste several lines at once, the first space in the second line gets interpreted as a newline, breaking the code.

This is still much better than nothing, so will play with it some more.

Am I right in believing that a remote python debugger can never give me REPL?

Thanks again,
E.

Hallo Steve,
Im super fond of python scripting in rhino, using mac. I also find that using a REPL is extremely powerful for developing scripts and feeling out the behavior of an API. This a little vote for a REPL in mac rhino!

I tried TestInteractivePython in Rhino 6 WIP and found it not to be working. It does work in rhino 5. Does this mean it is going away in Rhino 6?

It could certainly use some improvement, line Zmei said, so that one could swipe multiple lines out of a script and copy them into the interactive window. I could get a lot of benefit out of this if it worked a bit better. Even now, with one line-at-a-time swipe and copy, it could save me considerable time in developing some of my scripts.

Please say you will continue this in Rhino 6.

I see that this command now has an error occurring when attempting to set up paths. I don’t intend on making this command go away, but I also don’t see us putting much work into this in the near future. It is a test command which is something we use for very early prototypes.

Anything you can do to get it working in Rhino 6 WIP will be much appreciated. Currently all my time in Rhino 6 WIP is spent writing Pythonscripts and this command can help.