Showing results for 
Search instead for 
Do you mean 

SNAP Output Messagebox



Just a quick question about messagebox in SNAP. Seems like SNAP (NX10) doesn't have a special message  box, only one you can use is the WinForm messagebox.


I would like to use something like NXOpen.UI.GetUI.NXMessagebox(). I don't want Windows messagebox, I don't want Information Window, all I want is a NX message box.


Reason is windows box will "freeze" your interface, but NX message box will still allow you rotate your view (although you can't click anything else but at least your session is not frozen). Plus NX message box matches NX dialog style.


Does anyone have a way?





Re: SNAP Output Messagebox

"I would like to use something like NXOpen.UI.GetUI.NXMessagebox()."


What's stopping you from using the NXMessagebox?

Re: SNAP Output Messagebox

Thanks for your replay. I only have a SNAP license... I don't have NX Open license...


If I call NXOpen.UI.GetUI.NXMessagebox(), it will show error indicating a "invalid license signature".

Kinds of frustrated if SNAP (supposed to be easy and simple) doesn't support such a simple NX message box...

Re: SNAP Output Messagebox

Are you compiling the code or running it as a journal? If you want to compile it, you will need an author license, which I think is separate from the SNAP license. If you are OK with running the code as a journal (i.e. you don't need any functionality required by compiled code), it should work. There is an example here that uses the NXMessagebox, it works when run as a journal.

Re: SNAP Output Messagebox

Thanks cowski, if I run as Journal it will work because I do have a fully functioning journal for what I'm trying to do here.


I'm converting my journal files into SNAP program because occationally journal code will crash NX (hit & miss) and also we want to have better performance and better interface, so we have bought SNAP license. We thought SNAP should cover our simple need and give us a more reliable and user-friendly program.


Thanks cowski. If I somehow figured it out, I'll let you know too. Hopefully. Smiley Happy

Re: SNAP Output Messagebox

> I'm converting my journal files into SNAP program because occationally

> journal code will crash NX (hit & miss)


If you can reproduce these crashes, you should report them, so that they can be fixed. 


SNAP is buit on top of NX/Open, so if your NX/Open program crashes, a SNAP program that (internally) calls the same NX/Open functions will probably crash, too.


Adding a MessageBox capability to SNAP would probably be fairly easy. Please submit an ER.


Re: SNAP Output Messagebox

[ Edited ]

Here is a hack using a SNAP BlockForm.

In your code, all you need is the call to SnapMessageBox.ShowBox, as in my Main function.

If you don't like the design, you could do something similar, but using other types of blocks.

For example, a Button with a label works nicely for a single line of text.

Option Infer On
Imports Snap

Public Class SnapMessageBox: Inherits UI.BlockForm

   Dim textBlock As UI.Block.MultilineString

   ' Constructor for a SnapMessageBox object
   Private Sub New(title As String, message As String())

      Me.Title = title         
      Me.Cue   = "Please read the info in the Message Box"   

      ' Create a text block
      textBlock = New UI.Block.MultilineString()
      textBlock.Value = message
      textBlock.Label = ""
      textBlock.Enabled = False


   End Sub

   Public Shared Sub ShowBox(title As String, message As String())
      Dim box = New SnapMessageBox(title, message)
   End Sub

End Class

Public Class MyProgram

   Public Shared Sub Main()

      Dim title = "Message Box Hack"
      Dim message = { "Here is some text.", "And some more.", "And this is the last" }
      SnapMessageBox.ShowBox(title, message)

   End Sub

End Class



Re: SNAP Output Messagebox

Hi Yamada!


Unfortunately, those crashes are not duplicable. It's hit & miss. Since I'm using a different method in SNAP hopefully it will work fine.

I'll submit an ER about a message box.


Thanks for your help!!!



Owen Zhou

Re: SNAP Output Messagebox

That's a smart way!!! I was thinking about similar thing and here you go!

Really appreciated!!


Owen Zhou


Re: SNAP Output Messagebox



I have tried the method you've provided and it works. Do you know how to control the "Width" of the dialog?

I have multiple lines of strings but the block looks too small to display them all. I don't want user to manually resize the dialog in order to see full message.


I set miniHeight property of Multi-String block, however, the "Width" property doesn't really help.


Do you know anyway to size the dialog? Thanks!


Owen Zhou