Finding the Correct Object

I am trying to bring this dialog up to ask a question and am perplexed how to get the “Object Parent”. This requires a System.Object. I think this should be a reference to main Rhino Window but I cant find a way to hook it up through “this.parent” or anything else I have tried. Help with the syntax would be much appreciated.

        var result = Dialogs.ShowMessage(
            'Object Parent' (System.Object),
           "Are you sure?", 
            "Reset",	
            ShowMessageButton.YesNoCancel,
            ShowMessageDefaultButton.Button1,
            ShowMessageOptions.SetForeground,
            ShowMessageMode.ApplicationModal
            );

Best;

Steve

Hi Steve, you might try Rhino.RhinoApp.MainWindow

_
c.

C:

Tried that and it returns a struc:

Rhino.RhinoApp.MainWindow is now obsolete and has been taken over by:

IntPtr me = Rhino.RhinoApp.MainWindowHandle();

I thought that would have worked but it returns the wrong type. Maybe this dialog is no longer supported or we just have not hit on the special sauce yet.

I am running this from a command in a plug in but I don’t think the environment should be the issue.

Thanks!!

Steve

Hi Steve, i’ve only tried this in Python, no obsolete warning in V6 and V7.

@dale might know more sauce.

_
c.

clement:

Interesting I am running

// Assembly RhinoCommon, Version=7.2.21021.7001, Culture=neutral, PublicKeyToken=552281e97c755530

/// Main Rhino Window
/// 5.0
/// deprecated 6.0 deprecated
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete(“Use MainWindowHandle or RhinoEtoApp.MainWindow in Rhino.UI”)]
public static IWin32Window MainWindow()
{
if (RhinoApp.g_main_window == null)
{
IntPtr handle = RhinoApp.MainWindowHandle();
if (IntPtr.Zero != handle)
RhinoApp.g_main_window = new RhinoWindow(handle);
}
return (IWin32Window) RhinoApp.g_main_window;
}

But it does say to use RhinoEtoApp.MainWindow. I have tried to use both of these but maybe my call is incorrect or I am using the wrong version of the API.

Best;

Steve

Hm, just curious, if you paste this into _EditPythonScript in V7, does it blend ?

import Rhino

def DoSomething():
    
    rc = Rhino.UI.Dialogs.ShowMessage(
                                    Rhino.RhinoApp.MainWindowHandle(),
                                    "Hello Steve !",
                                    "Title",
                                    Rhino.UI.ShowMessageButton.OKCancel,
                                    Rhino.UI.ShowMessageIcon.Information,
                                    Rhino.UI.ShowMessageDefaultButton.Button1,
                                    Rhino.UI.ShowMessageOptions.None,
                                    Rhino.UI.ShowMessageMode.ApplicationModal
                                    )
    
    if rc != Rhino.UI.ShowMessageResult.OK: return
    
    print "You pressed OK"
    
DoSomething()

I get no error here in V6 but thats only Python.

_
c.

Clement:

Thank you so much!!

That was it, I got the signature wrong. When I pasted what you sent into the code everything worked. Turned out I forgot to add the Rhino.UI.ShowMessageIcon.Information, property.

Again thanks for helping out.

Thanks.

Best

Steve

1 Like