Ctrl + V to Paste Text in Command Line is Different Between Rhino 7 and 8

This is a question that’s possibly for @eirannejad as it’s related to my use of the Rhino 8 ScriptEditor, though @dale might also have some insight as he has answered questions similar to this in the past.

I am trying to write a command where the user can paste a URL or file path into the command line. Here is some sample code:

import Rhino

url_input_request = Rhino.Input.Custom.GetString()
url_input_request.SetCommandPrompt('Paste a URL here.')
while True:
    get_url = url_input_request.Get()
    if get_url == Rhino.Input.GetResult.String:
        url_path = url_input_request.StringResult()
        print(url_path)
    break

In Rhino 8, I am able to use Ctrl + V to paste the URL without issues like so:
CtrlV Works in Rhino 8

However, in Rhino 7, I just get the following:

Paste a URL here.: '_Paste
Paste a URL here.: https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/USA/NY/USA_NY_New.York-J.F.Kennedy.Intl.AP.744860_TMY3/USA_NY_New.York-J.F.Kennedy.Intl.AP.744860_TMY3.zip
Unknown command: https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/USA/NY/USA_NY_New.York-J.F.Kennedy.Intl.AP.744860_TMY3/USA_NY_New.York-J.F.Kennedy.Intl.AP.744860_TMY3.zip

Granted, I can still get things to work in either Rhino 7 or 8 by right-clicking in the command line and selecting “Paste”:

image

But I would really like to know: is there anythign that I could change about my code to get it to behave the same way in Rhino 7 as it does in Rhino 8? So the user would be able to use Ctrl + V and I could hopefully avoid users getting confused about this like this case here?

Thank you, as always.

Hi @chris12,

For Rhino 7, I don’t have any great ideas, other than this:

import rhinoscriptsyntax as rs

rc = rs.StringBox('Paste a URL here.', None, 'Ladybug')
if rc:
    print(rc)

– Dale

1 Like

Thanks @dale ,

I appreciate the suggestion, though it’s probably not the best fit for my case.

If I’m being honest, the main reason why I have this step of the command is to give people a bunch of options that I have attached to the Rhino.Input.Custom.GetString instance, while also letting people change this URL or file path. So, if I’m going the “StringBox” route, I’m probably looking at leaving the domain of the Rhino command line and re-doing all of these options in an Eto or WPF display, which is probably a little overkill.

Maybe I just have to tell people to upgrade to Rhino 8. I really appreciate that the Ctrl + V works correctly over there.

You may have more success with GetString.GetLiteralString; I remember that I had to use this if the user wanted to give a string with spaces. This may be a different issue though.

https://developer.rhino3d.com/api/rhinocommon/rhino.input.custom.getstring/getliteralstring