Thedialog.show() error - Block UI styler
Thedialog.show() error - Block UI styler
(OP)
hi,
I'm slowely starting to understand how all the dialog/journaling things work in nx, but I'm beeing held back from progressing because of this error I'm getting. Even in the most basic program I always get the same error.
The error is located in the sub main() & goes something like "nameofdialog.show()", but I have no clue to what I'm doing wrong. I've added the code in attachment
Greetings
(My goal is to create a dialog & implement pieces of a journal in the vb-project. But I'm kind of stuck @ the creating a dialog part.)
I'm slowely starting to understand how all the dialog/journaling things work in nx, but I'm beeing held back from progressing because of this error I'm getting. Even in the most basic program I always get the same error.
The error is located in the sub main() & goes something like "nameofdialog.show()", but I have no clue to what I'm doing wrong. I've added the code in attachment
Greetings
(My goal is to create a dialog & implement pieces of a journal in the vb-project. But I'm kind of stuck @ the creating a dialog part.)





RE: Thedialog.show() error - Block UI styler
Graham Inchley, Systems Developer.
NX6, NX8.5(testing)
www.sandvik.com
RE: Thedialog.show() error - Block UI styler
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
RE: Thedialog.show() error - Block UI styler
What version of NX are you using?
Can you attach the DLX file?
Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 8GB. Developing in: Java | C | C# | KF
Production: NX6.0.5.3 MP5
Testing: NX8.5.3.3 MP4 64bit | NX9.0.2.5
RE: Thedialog.show() error - Block UI styler
I've attached the DLX to this message
RE: Thedialog.show() error - Block UI styler
The only thing I changed was to hardcode the path to the DLX file to save me having to put it into my real NX environment.
Note: I've only tested in NX8.5, I don't have time to test in NX9 right now, sorry. Can't imagine why it would fail though.
Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 8GB. Developing in: Java | C | C# | KF
Production: NX6.0.5.3 MP5
Testing: NX8.5.3.3 MP4 64bit | NX9.0.2.5
RE: Thedialog.show() error - Block UI styler
Well thanks for trying anyways!