Endless "Work in Progress" Box

I have some code that displays a form which retrieves an expression value from NX and displays it in a textbox on the form if the textbox value is changed by the user the expression value is updated to the new value. I am using this method on a bunch of expressions but the problem I am running into is when i change the value and apply it using an "Apply" Button on my form I get a message box for "Work in Progress" that never closes even after the value has updated.

Dim Exp As NXOpen.Expression = CType(workPart.Expressions.FindObject("OS_OD"), NXOpen.Expression) 'get expression
Dim ob1 As TextBox = TextBox1 'get string from textbox
Dim Val As String = MainMenu.OSA 'get expession value

If IsNumeric(Trim(ob1.Text)) = True And ob1.Text <> Exp.Value Then 'check if text box is a number and different from current value

workPart.Expressions.Edit(Exp, ob1.Text) 'expression = to TB text

Else
MsgBox("Please Enter a valid numerical value selected field", vbOK) 'error found in TB string
ob1.Select()
End If

Did you get this issue sorted?
If not, can you post your code (or at least enough to show the problem)?

I have not, for now I am just moving the "Work in progress" window out of the way and it lets me continue as if it is not there, but it does not disappear until I close the entire program, using my main form. I have narrowed it down to this line of code.

workPart.Expressions.Edit(Exp, ob1.Text) 'expression = to TB text

when I comment this out the window will go way but the expression will not be edited if I do so. The program is rather long it has a main menu that is used to call several sub menu's, so I only posted a small section of the program. I am thinking that I am not unloading something properly and NX is awaiting further feedback from my form.

Imports System
Imports System.Threading
Imports System.Reflection
Imports System.Windows.Forms
Imports System.Math

Imports System.Collections
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim TheSession As NXOpen.Session = Session.GetSession()
Dim workPart As NXOpen.Part = TheSession.Parts.Work

' data verification of testbox1 value
Dim Exp As NXOpen.Expression = CType(workPart.Expressions.FindObject("OS_OD"), NXOpen.Expression) 'get expression
Dim ExpName As String = "OS_OD"
Dim Exp1 As NXOpen.Expression = MainMenu.OS_OD
Dim ExpDec As Decimal = MainMenu.OS_OD.Value
Dim ob1 As TextBox = TextBox1 'get string from textbox
Dim Val As String = MainMenu.OSA

If IsNumeric(Trim(ob1.Text)) = True Then 'check if text box is a number and different from current value

workPart.Expressions.Edit(Exp, ob1.Text) 'expression = to TB text

'update values in TB
Exp1 = CType(workPart.Expressions.FindObject(ExpName), NXOpen.Expression)
ExpDec = Exp1.Value
Val = (Trim(ExpDec.ToString("0.0000")))
ob1.Text = Val

Else

MsgBox("Please Enter a valid numerical value selected field", vbOK) 'error found in TB string
ob1.Select()

End If
MainMenu.TheSession.UpdateManager.DoUpdate(MainMenu.TheSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "NX update"))

End Sub

As for the Forms I made them in Visual Studio's Form Designer, they are not NX Forms

Jason Burdette

Nothing in your code snippet jumps out at me, but I think you are on the right track. I suspect that NX wants to perform an update because the expression has been edited but is waiting for the form to close. If this is the case, you might try passing the information from the form back to the module, closing the form, and then updating the expression from the module code. That's the strategy I use in the form demo code (link below). That way, if the user presses Cancel, I just close the form and ignore the input from the form. If the user presses OK, I close the form and update the part file (attributes, in my case).

http://nxjournaling.com/content/using-winforms-journals

I'm not 100% certain this will solve your issue, but it is what I'd try next.

I think I have figured out the problem, I am calling the Form using form.ShowDialog() which does not allow any updating within NX until the form has closed. Whereas if I used form.Show(), I could still operate NX while the form is open. The problem i am running into is that I am actively manipulating a model using the form so I think I need to use the "form.ShowDialog()" to update my data correctly. I am looking for a way around this currently but haven't found a way to make the form operate as needed using the "form.Show()". I determined this after reading through the PDF linked below.

http://files.engineering.com/download.aspx?folder=bf45e0bf-ed1a-4051-888...

Jason Burdette

If you want to use the form.Show functionality, I think you need to compile your code. You might need a .net author license for full functionality.