WindowID of Mechanical main windows for message box

How I get the WindowID of the Mechanical main window to pop up an error message?
MessageBox.Show(???, "Message Box Text", "Message Box Title", MessageBoxType.Error, MessageBoxButtons.OK)

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Member, Moderator, Employee Posts: 888
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    @ThomasDD I don't think this info is needed. Use:

    1. clr.AddReference("Ans.UI.Toolkit.Base")
    2. clr.AddReference("Ans.UI.Toolkit")
    3. from Ansys.UI.Toolkit import *
    4. MessageBox.Show('test')

    or:

    1. msg = Ansys.Mechanical.Application.Message('my Warning message as string...', MessageSeverityType.Warning)
    2. ExtAPI.Application.Messages.Add(msg)
  • Member Posts: 20
    10 Comments Name Dropper
    **

    The first answer is known to me. The problem is that the icon cannot be changed.

    The second thing I will try. Thanks!

  • Member Posts: 20
    10 Comments Name Dropper
    **

    ChatGPT gave me the right answer!

    MessageBox.Show(ExtAPI.UserInterface.MainWindow, "Message Box Text", "Message Box Title", MessageBoxType.Error, MessageBoxButtons.OK)

  • Member Posts: 20
    10 Comments Name Dropper
    **

    ExtAPI.UserInterface.MainWindow seems to work. I get an error message that blocks the Mechanical Window until you click on OK. But the focus on the main Window seems lost after that. It seems that ExtAPI.UserInterface.MainWindow is a small and invisible window and not the Mechanical main window.

    ExtAPI.UserInterface.MainWindow.Width returns "2" only, for example...

  • Member Posts: 20
    10 Comments Name Dropper
    **

    ExtAPI.UserInterface.MainWindow.Width = 200
    ExtAPI.UserInterface.MainWindow.Height = 200

    If you change the size of ExtAPI.UserInterface.MainWindow, you see that mysterious thing at the top left corner of the Mechanical Window:

Welcome!

It looks like you're new here. Sign in or register to get started.