I've just created an example, since every dialog returns the same dialog.
This code is directly copied from the blockUI styler.
The error is located in the public sub show()
A NullReference, i do know what it means, that I'm using something that's not defined, but can't seem to figur out what's wrong.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.BlockStyler
'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class Testdouble
'class members
Private Shared theSession As Session
Private Shared theUI As UI
Private theDlxFileName As String
Private theDialog As NXOpen.BlockStyler.BlockDialog
Private group0 As NXOpen.BlockStyler.Group ' Block type: Group
Private double0 As NXOpen.BlockStyler.DoubleBlock ' Block type: Double
#Region "Block Styler Dialog Designer generator code"
'------------------------------------------------------------------------------
'Constructor for NX Styler class
'------------------------------------------------------------------------------
Public Sub New()
Try
theSession = Session.GetSession()
theUI = UI.GetUI()
theDlxFileName = "Testdouble.dlx"
theDialog = theUI.CreateDialog(theDlxFileName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddOkHandler(AddressOf ok_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
Catch ex As Exception
'---- Enter your exception handling code here -----
End Try
End Sub
#End Region
Public Shared Sub Main()
Dim theTestdouble As Testdouble = Nothing
Try
theTestdouble = New Testdouble()
' The following method shows the dialog immediately
theTestdouble.Show()
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
Finally
If theTestdouble IsNot Nothing Then
theTestdouble.Dispose()
theTestdouble = Nothing
End If
End Try
End Sub
Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
Return CType(Session.LibraryUnloadOption.Immediately, Integer)
' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
End Function
'------------------------------------------------------------------------------
' Following method cleanup any housekeeping chores that may be needed.
' This method is automatically called by NX.
'------------------------------------------------------------------------------
Public Shared Sub UnloadLibrary(ByVal arg As String)
Try
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'This method shows the dialog on the screen
'------------------------------------------------------------------------------
Public Sub Show()
Try
theDialog.Show()
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'Method Name: Dispose
'------------------------------------------------------------------------------
Public Sub Dispose()
If theDialog IsNot Nothing Then
theDialog.Dispose()
theDialog = Nothing
End If
End Sub
Public Sub initialize_cb()
Try
group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.Group)
double0 = CType(theDialog.TopBlock.FindBlock("double0"), NXOpen.BlockStyler.DoubleBlock)
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
Public Sub dialogShown_cb()
Try
'---- Enter your callback code here -----
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'Callback Name: apply_cb
'------------------------------------------------------------------------------
Public Function apply_cb() As Integer
Dim errorCode As Integer = 0
Try
'---- Enter your callback code here -----
Catch ex As Exception
'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
apply_cb = errorCode
End Function
'------------------------------------------------------------------------------
'Callback Name: update_cb
'------------------------------------------------------------------------------
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try
If block Is double0 Then
'---- Enter your code here -----
End If
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
update_cb = 0
End Function
'------------------------------------------------------------------------------
'Callback Name: ok_cb
'------------------------------------------------------------------------------
Public Function ok_cb() As Integer
Dim errorCode As Integer = 0
Try
'---- Enter your callback code here -----
errorCode = apply_cb()
Catch ex As Exception
'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
ok_cb = errorCode
End Function
'------------------------------------------------------------------------------
'Function Name: GetBlockProperties
'Returns the propertylist of the specified BlockID
'------------------------------------------------------------------------------
Public Function GetBlockProperties(ByVal blockID As String) As PropertyList
GetBlockProperties = Nothing
Try
GetBlockProperties = theDialog.GetBlockProperties(blockID)
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Function
End Class