cancel
Showing results for 
Search instead for 
Did you mean: 

SNAP Output Messagebox

Creator
Creator

Hello,

 

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?

 

Thanks.

Owen~~

14 REPLIES

Re: SNAP Output Messagebox

Phenom
Phenom

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

 

What's stopping you from using the NXMessagebox?

Re: SNAP Output Messagebox

Creator
Creator

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

Phenom
Phenom

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

Creator
Creator

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

Siemens Phenom Siemens Phenom
Siemens Phenom

> 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.

山田
yamada

Re: SNAP Output Messagebox

Siemens Phenom Siemens Phenom
Siemens Phenom

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

      Me.AddBlocks(textBlock)

   End Sub

   Public Shared Sub ShowBox(title As String, message As String())
      Dim box = New SnapMessageBox(title, message)
      box.Show
   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

 

山田
yamada

Re: SNAP Output Messagebox

Creator
Creator

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!!!

 

Regards,

Owen Zhou

Re: SNAP Output Messagebox

Creator
Creator

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

Really appreciated!!

 

Owen Zhou

 

Re: SNAP Output Messagebox

Creator
Creator

山田君,

 

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