Rhino Python interface methods weirdness

Hi,

I’ve been playing a bit with iron python and the rhinoscriptsyntax library. It’s really quite cool, but I have noticed several problems with some of the calls.

rs.GetBoolean doesn’t seem to work at all,

rs.PopupMenu crashes rhino (elegantly…)

and I problems with rs.RealBox but rs.GetReal worked fine.

( FWIW, it would be great to have a method to create some sort of mixed input panel which would allow entry of numbers, text and boolean checkboxes all in the one place…)

Finally, is there any way at all to point directly to a specific script in the command line, rather than just runPythonScript giving a open file dialogue box?

thanks for the wonderful work!

cheers
Peter

On Mac, you’re going to have some patience, as not all the rhinoscriptsyntax methods have been implemented - the Mac version is somewhat outdated (Steve is working on it). Many of the UI methods like …Box (ListBox, StringBox, etc. ) rely on WindowsForms and will crash or refuse to work on Mac. Most of the Get… methods work fine, because that is command-line input. GetBoolean, however, does not appear to work…

To run a python script directly, first, store your script in the “default” folder on Mac:

/Users/<username>/Library/Application Support/McNeel/Rhinoceros/Scripts

Then, create an alias with a macro like:

! _-RunPythonScript ScriptName.py (I think you can leave the .py off too)

Typing the alias and Enter will run the script.

–Mitch

Oh, and I’ve asked for this in Windows for a long time… I think it’s possible to mix input types on the command line in Windows with the RhinoCommon GetBaseClass, but I haven’t actually tried yet… But a panel would be great.

–Mitch

That all makes sense. I just thought I’d make sure they were on your list :smile:

Thanks for the info on running the script directly. I thought running a script must be something like that and I tried every combination of () and “” etc but didn’t think of just plain text for the filename. Doh!

BTW, can you pass a variable to the script that way?

cheers Peter

Thanks Mitch, never thought of running the script direct. I use the weight one (with unobtanium) you did a while ago. Because of OSX & ListBox, I made it just for silver 925. I have an alias to runPhythonScript, but would then have to select the script. That is OK for some that I only use occasionally, but the weight I use on every job.
randy

This should be fixed in the next release of Mac Rhino :smiley:

@curtisw helped get these user interface items implemented in Eto
http://mcneel.myjetbrains.com/youtrack/issue/MR-742

1 Like

Yee haw!!! :star: :star: :star: :star:

4 Likes

@stevebaer I have just a teensy weensy little additional request while you’re into UI methods… ***MultiListBox()***… Been waiting for this one for a looooooong time on both the Windows side as well as Mac… So now’s a chance do do a cross-platform thing… :smile:

Thanks, --Mitch

Yep, I didn’t want to add any more user interface oriented functions to rhinoscriptsyntax until we figured out how we would support this on OS X. Creating more of these functions on Windows that just plain didn’t work on OS X is not acceptable to me for a library that is supposed to work on both platforms. Thanks to @curtisw and his Eto project we now don’t have that barrier and can move forward with getting these other dialogs that are standard in our scripting environments working.

I’m not saying this will be done tomorrow, just that this is now a possibility :smile:

You could also create your own custom UI using Eto directly in python:

import clr
clr.AddReference("Eto")
clr.AddReference("Rhino.UI")

from Rhino.UI import *
from Eto.Forms import *
from Eto.Drawing import *

obj = Dialog()
obj.Title = "Some Dialog"
obj.ClientSize = Size(200, 200)

label = Label()
label.Text = "Hello, Python"
obj.Content = label

obj.ShowModal(RhinoEtoApp.MainWindow)
1 Like

I guess this means that you have to have ETO installed on the computer somehow/somewhere…? --Mitch

It is included with Mac Rhino and will be included in V6 for Windows

1 Like

hey curtis, all

i’m experiencing some weirdness with these dialogs… for instance, if i do this:

number = rs.RealBox("Enter a number", 10)

… the box shows up:



the weird bit is i can only enter a single key… the 10 will change to that number but i can’t enter anything else… (if i try to enter 25, the dialog will get stuck at 2.000 )

after it’s stuck, i can then type numbers 6-9 and the last decimal increases by 1…

2.001
2.002
2.003

etc.

if i click on the arrow up/down, this is what displays in the field: (and remains stuck)

-123,432,101,234,321,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000

i’ll try to clarify a bit better or send a video if need be…

(@ anyone else on mac… are these boxes working right for you?)

Hey jeff,

Try something like this:

number = rs.RealBox("Enter a number", 10, "", 0, 1000)

The issue seems to be that the default minimum and maximum values are set to an incorrect value. I fixed that for ShowNumberBox, but not for RealBox.

This looks cool. Were do we find more information & commands. Trying to set up some dialog boxes that give me a choice of items and then print that as a text block in Rhino.

OK got this part.

Two more things; which imports inside the red box are necessary to use ETO for dialogue boxes?

Also if using ATOM as editor and implemented like suggested by @jeff_hammond in this thread, The rhino-python package for the Atom text editor and Rhino for Mac - #39 by Jess , then the dialogue box is coming up twice. Once when you use the ⌘R in ATOM and then again once the rhino window takes focus.

Thanks, Randy