Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

NXopen Python show message box in NX 10


Hi I try to show a messagebox with NX python.

I was used to it in Java in and C# but in Python i get some problems:

This is my code:


NXOpen.NXMessageBox.Show("test",NXOpen.NXMessageBoxDialogType.Information,"Hello World")



TypeError: descriptor 'Show' requires a 'NXOpen.NXMessageBox' object but received a 'str'.


But why? what is the object. In the documentation there is only the method Show described which requires :

  • Show(title, msgboxType, message)

What is wrong in my call?


Re: NXopen Python show message box in NX 10



Good morning.  It is hard to tell from just one line of code what might be happening, although I don't see any obvious errors in that line.


There is an example program in the NX10 folders that uses this call, at:




You might take a close look at the example and see if you can spot any differences in your program.  I tested the example, and it worked fine for me - it posted the message box several times successfully.


Re: NXopen Python show message box in NX 10


This worked:

    theUI = NXOpen.UI.GetUI()
    myMsgBox = theUI.NXMessageBox
    myMsgBox.Show("Test", NXOpen.NXMessageBox.DialogType.Information,"Hello World")

Accepted by topic author BehNouri
‎10-06-2015 12:03 PM

Re: NXopen Python show message box in NX 10

[ Edited ]

Your line of code is simply the name of the class (NXOpen.NXMessagebox), which is a string (str).


To call the Show method, you first need to instantiate an object of the NXMessageBox class from the NXOpen.UI object. The NXOpen.UI object in turn is instantiated from UI.GetUI:


theUI = NXOpen.UI.GetUI()
theNxMessageBox = theUI.NXMessageBox
theNxMessageBox.Show("test", NXOpen.NXMessageBox.DialogType.Information,"Hello World")


If you really want a single line of code, the following will work:


NXOpen.UI.GetUI().NXMessageBox.Show("test", NXOpen.NXMessageBox.DialogType.Information, "Hello World")

Re: NXopen Python show message box in NX 10

Thank you that works

Re: NXopen Python show message box in NX 10

[ Edited ]

You can also use the listing window


import NXOpen.UF

self.theSession = NXOpen.Session.GetSession()
self.theLw = self.theSession.ListingWindow

#open console and print to it
self.theLw.WriteLine("Your variable  name is "+str(variable))