Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thedialog.show() error - Block UI styler 1

Status
Not open for further replies.

Obito

Mechanical
Nov 27, 2014
6
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.)

 
 http://files.engineering.com/getfile.aspx?folder=1d264de4-f88d-499b-bded-6ad1de614cfb&file=Fault.PNG
Replies continue below

Recommended for you

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
 
Interesting. I can't actually see anything wrong.
What version of NX are you using?
Can you attach the DLX file?

Graham Inchley, Systems Developer, Sandvik Coromant. 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
 
Executing dlg.vb as a journal runs fine for me.
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. 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
 
Hmm, very strange..
Well thanks for trying anyways!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor