NXKnowledge

NX Open Programmer's Guide > Block Styler Automation > Launching Block Styler Dialogs from NX

Launching Block Styler Dialogs from NX

Launching an application that uses one or more Block dialogs is almost identical to launching any other Interactive NX Open application. The only difference is that your application will need to find the DLX file at runtime.

Note: A Batch or Remote application would never be able to launch a Block dialog.

Finding the DLX File at Runtime

The template code comments include a section on launching the dialog. This section contains comments to remind you where to place the DLX for NX to be able to locate the file at runtime. Finding DLX files is also covered in Application Directory Structure. You have the following two options:

  1. Place the DLX file in an application folder that is contained in a folder that is referenced by one of the search options discussed in Application Directory Structure. This is the recommended method and should definitely be used when distributing your application to multiple users.
  2. Hard code the full path name in the source file (not recommended for distribution).

Entry Point Options

The template code can include one or more of the following standard entry points: Menu and User Exit. Or the template code can include a unique entry point that you will call from a larger application — this is most likely the method used if your executable uses more than one dialog. The Block Styler provides the Callback Entry Point option for this type of template code.

The Block Styler Code Generation options provide the following three Entry Point options:

  • User Exit
  • Menu
  • Callback

Note: You can choose to include any combination of these entry point options in the template code. However, if more than one option is selected, all options will be commented out — you will need to uncomment the method that you want to use.

Note: All code examples in this section are based on a dialog named testBlockDialog.

User Exit

This option generates a standard User Exit entry point for the selected language. The default entry point generated in the template code is the entry point tied to the File tab → Execute → NX Open action. For more information see Executing applications from existing menus and Executing applications from new menu items.

Callback

This option provides an entry point that you can call from a larger application.

User Exit Entry Point Option — Language Specific Details

NX Open for C++

The standard User Exit entry point and dialog initialization for C++ is:

extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
    try
    {
        thetestBlockDialog = new testBlockDialog();
        // The following method shows the dialog immediately
        thetestBlockDialog->Show();
    }
    catch(exception &ex)
    {
        //---- Enter your exception handling code here -----
        testBlockDialog::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
    delete thetestBlockDialog;
}

The call to the Show method will display the dialog and control will not return until the user closes the dialog or hits the Ok or Cancel buttons. All of your interaction with the dialog will be via the callback methods discussed in Block Styler Callbacks and Block Styler Update.

You can add code to this function but it is not necessary. A specific initialize callback is provided for dialog startup and a standard destructor method is provided for dialog shutdown and cleanup.

This entry point is used when you want to execute your dialog using File tab → Execute → NX Open or with a Menu Button.

NX Open for .NET

The standard User Exit entry point and dialog initialization for Visual Basic .NET is:

Public Shared Sub Main()
    Try
      thetestBlockDialog = New testBlockDialog()
      ' The following method shows the dialog immediately
      thetestBlockDialog.Show()
    Catch ex As Exception
      '---- Enter your exception handling code here -----
      theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Finally
      thetestBlockDialog.Dispose()
    End Try
End Sub

You can add code to this subroutine but it is not necessary. A specific initialize callback is provided for dialog startup and a standard dispose method is provided for dialog shutdown and cleanup.

This entry point is used when you want to execute your dialog using File tab → Execute → NX Open or with a Menu Button or with Developer tab → Journal group → Play.

NX Open for Java

The standard User Exit entry point and dialog initialization for Java is:

public static void main(String [] argv) throws Exception
{
   try
   {
     thetestBlockDialog = new testBlockDialog();
     // The following method shows the dialog immediately
     thetestBlockDialog.show();
   }
   catch(Exception ex)
   {
     //---- Enter your exception handling code here -----
     theUI.nxmessageBox().show("Block Styler", nxopen.NXMessageBox.DialogType.INFORMATION, ex.getMessage());
   }
   finally
   {
     thetestBlockDialog.dispose();
   }
}

You can add code to this function but it is not necessary. A specific initialize callback is provided for dialog startup, and a standard dispose method is provided for dialog shutdown and cleanup.

This entry point is used when you want to execute your dialog using File tab → Execute → NX Open or with a Menu Button.

Callback Entry Point Option — Language Specific Details

NX Open for C++

The callback entry point and dialog initialization in C++ is:

void testBlockDialog::Show_testBlockDialog()
{
  try
  {
    thetestBlockDialog = new testBlockDialog();
    // The following method shows the dialog immediately
    thetestBlockDialog->Show();
  }
  catch(exception &ex)
  {
    //---- Enter your exception handling code here -----
    testBlockDialog::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
  }
  delete thetestBlockDialog;
}

NX Open for .NET

The callback entry point and dialog initialization in Visual Basic .NET is:

Public Shared Sub Show_testBlockDialog()
    Try
      thetestBlockDialog = New testBlockDialog()
      ' The following method shows the dialog immediately
      thetestBlockDialog.Show()
    Catch ex As Exception
      '---- Enter your exception handling code here -----
      theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
    Finally
      thetestBlockDialog.Dispose()
    End Try
End Sub

(Java's equivalent callback entry point follows the same Show_testBlockDialog()-style static-method pattern as the User Exit form above, adapted to a callable static method rather than main.)

This entry point is used when you want to call the dialog directly from a larger application. This is typically done when multiple dialogs are required for the application. The Show_testBlockDialog() method is declared as a static function so that it may be called directly without having to create a testBlockDialog object.

Related Topics

  • Block Styler Automation
  • Block Styler Memory and Callbacks
  • Dialog and Block Properties
  • Block Styler Selection Blocks
  • Block Styler Update Callback

Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/block_styler_launch · retrieved 2026-07-07