Long inline Python script within a Rhinoscript?

I’m trying to create a double clickable Rhino script that will open a Windows file path that has been copied to the clipboard. Since Rhinoscipt itself didn’t let me do that when there were any spaces in the path, I resorted to Rhinocommon to avoid the command line treating spaces like the enter key. Though I can assign the following as a toolbar button macro:

-RunPythonScript (
import Rhino
import System.Windows.Forms.Clipboard
CLIPBOARD = System.Windows.Forms.Clipboard.GetText()

…I cannot get it to run as a normal EditScript editor program since the parenthesis fails to allow a multiline Python script. I’m using Python since I’m used to invoking Rhinocommon with it.


Rhino.Command “-RunPythonScript (
import Rhino

…says Microsoft VBScript compilation error, unterminated string constant."

It’s especially frustraring since Rhinoscript is evidently itself written in Python.

This is necessary since saved Python script files associated with Rhino via default program assignment fail to run when double clicked.

I don’t want to have to maintain a separate Python file anyway, and again that causes issues with space characters in the path from within a EditScript program. I’m even confused what EditScript language is beyond being able to invoke Rhinoscript commands.

Hi Nik

To pass a path (or any string) with spaces to the commandline you should surround it by double quotes.

Here’s an example:

  ' If the picked a file that has a space character in its name,
  ' or resides in a folder that has a space character, then we
  ' need to surround the file string in double-quotes so Rhino's
  ' command line parser will interpret the string correctly.
  strFile = Chr(34) & strFile & Chr(34)
  ' Now we can simply script Rhino's Open command to open the file.
  Call Rhino.Command("_-Open " & strFile, 0)

Hope this gets you out the code hole you dug yourself into.


Multiline python scripts are supported

Neither answer is responsive since the first ignores my need to just run multi-line Python scripts from within a single saved Rhinoscript file and the second ignores how multi-line Python scripts only work in a toolbar button macro but not in the normal EditScript editor. I’m a Python user with utterly no interest in learning the arbitrary rules of a weird EditScript system that spits out VBScript errors. Is it really some form of Visual Basic with a Python library built in called “Rhinoscript”? That’s crazy. What isn’t crazy is just using Python and good old deep level Rhinoscript. But McNeel won’t let me run Python as a double-clickable Windows file. So I need to have a simple EditScript wrapper for nicely debugged EditPythonScript programs. I still don’t have that since it spits out an error when I try to use multiple lines.

The double quotes strategy was of course the first thing I tried, but it usually fails since Rhinoscript is sending keystrokes instead of using Rhinocommon, evidently. The first solution since uses a seemingly undocumented Call command that indirectly invokes Rhinoscript?! That’s not helpful, just bewildering.

Sorry, but I must be confused as to what it is you are trying to do. At first I thought you were just trying to get a python script to run from a toolbar butting, but after reading this and rereading your first post I’m not sure what you want to do. What is it that you are trying to “double click” on to execute? Is this a separate file outside of Rhino?