ETO forms in Grashopper

Trying to learn how to use ETO.forms from this example: Rhino - Writing Custom Eto forms in Python (rhino3d.com)

I want to use this in a Grasshopper python component, but I can’t get it to output to a. Is there any reason this would not work? Is there another way I need to do this? The value is getting stored in a as I can print it, but the value in the output is empty.

# The script that will be using the dialog.
def RequestRoomNumber():
    dialog = SampleEtoRoomNumberDialog();
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    if (rc):
        outText = dialog.GetText()
        print(outText)
        a = outText

you need an event listener that tells grasshopper to update when the dialog contents change
however i don’t know whether grasshopper’s canvas updates when there a modal shown on top.

a is only defined locally. A quick and dirty fix would be to add the line: global a
just after the function definition.

1 Like

Thank you Mads. This is what I ended up doing.

The final definition looks something like this:

def RequestRoomNumber():
    global a
    dialog = SampleEtoRoomNumberDialog();
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    if (rc):
        outText = dialog.GetText()
    a = outText