Window Forms in NXOpen
Window Forms in NXOpen
(OP)
Hi all,
I have written the code bellow but while trying to execute it gives me an error message: "Error in the external library. See syslog for details ... Function name ufusr".
The form is supposed to load the existing expressions of breadth and thickness and assign them to two textboxes expression0 and experssion01.
Does anybody knows how to fix this?
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports System.Windows.Forms
Public Class Form1
Private Shared theSession As Session
Private Shared theUI As UI
Public nErrs1 As Integer
Public id1 As Session.UndoMarkId
Public workPart As Part = theSession.Parts.Work
Public displayPart As Part = theSession.Parts.Display
Dim nxopenSession As NXOpen.UF.UFSession
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
nxopenSession = NXOpen.UF.UFSession.GetUFSession()
'MeesageWindow
Dim MessageBoxTitle As String = "Track Expression"
'Find Expressions
Dim breadthExp As Expression = CType(theSession.Parts.Work.Expressions.FindObject("Breadth"), Expression)
Dim thicknessExp As Expression = CType(theSession.Parts.Work.Expressions.FindObject("thickness"), Expression)
'Convert Expressions' Values to Strings
Dim breadth As String = breadthExp.Value.ToString
Dim thickness As String = thicknessExp.Value.ToString
If breadthExp IsNot Nothing Then
expression0.Text = breadth
expression01.Text = thickness
If (breadth = 25 And thickness = 6) Then
theUI.NXMessageBox.Show(MessageBoxTitle, NXMessageBox.DialogType.Information, "yeah")
End If
'Force Update and redraw part
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
End If
End Sub
Private Sub Apply_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Apply_btn.Click
'Force Update and redraw part
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
End Sub
End Class
I have written the code bellow but while trying to execute it gives me an error message: "Error in the external library. See syslog for details ... Function name ufusr".
The form is supposed to load the existing expressions of breadth and thickness and assign them to two textboxes expression0 and experssion01.
Does anybody knows how to fix this?
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports System.Windows.Forms
Public Class Form1
Private Shared theSession As Session
Private Shared theUI As UI
Public nErrs1 As Integer
Public id1 As Session.UndoMarkId
Public workPart As Part = theSession.Parts.Work
Public displayPart As Part = theSession.Parts.Display
Dim nxopenSession As NXOpen.UF.UFSession
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
nxopenSession = NXOpen.UF.UFSession.GetUFSession()
'MeesageWindow
Dim MessageBoxTitle As String = "Track Expression"
'Find Expressions
Dim breadthExp As Expression = CType(theSession.Parts.Work.Expressions.FindObject("Breadth"), Expression)
Dim thicknessExp As Expression = CType(theSession.Parts.Work.Expressions.FindObject("thickness"), Expression)
'Convert Expressions' Values to Strings
Dim breadth As String = breadthExp.Value.ToString
Dim thickness As String = thicknessExp.Value.ToString
If breadthExp IsNot Nothing Then
expression0.Text = breadth
expression01.Text = thickness
If (breadth = 25 And thickness = 6) Then
theUI.NXMessageBox.Show(MessageBoxTitle, NXMessageBox.DialogType.Information, "yeah")
End If
'Force Update and redraw part
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
End If
End Sub
Private Sub Apply_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Apply_btn.Click
'Force Update and redraw part
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
End Sub
End Class





RE: Window Forms in NXOpen
CODE
www.nxjournaling.com
RE: Window Forms in NXOpen
Do you have any idea how we use the debugger of Visual Studio for Nx Open applications?
Also do you know anything about threads in NXOpen? I have the windows forms .exe (instead of using the journal) running and the moment when I change an expression the part changes and a window comes up saying "Work in progress".. Have you come up with a similar proplem before?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NXOpen;
using NXOpen.UF;
using NXOpen.UIStyler;
namespace LoadDLL_20082012
{
public partial class Form1 : Form
{
public Form1()
{
//Load expression
breadthExp = (Expression)theSession.Parts.Work.Expressions.FindObject("Breadth");
thicknessExp = (Expression)theSession.Parts.Work.Expressions.FindObject("thickness");
//Convert Expressions' Values to Strings
String breadth = breadthExp.Value.ToString();
String thickness = thicknessExp.Value.ToString();
this.breadth_box.Text = breadth;
this.thickness_box.Text = thickness;
}
public NXOpen.UI theUI = NXOpen.UI.GetUI();
public Session theSession = Session.GetSession();
public UFSession theUfSession = UFSession.GetUFSession();
public NXOpen.Session.UndoMarkId Id2;
public int nErrs1;
public Expression breadthExp;
public Expression thicknessExp;
private void level1_btn_Click(object sender, EventArgs e)
{
//theUfSession.UF.PrintSyslog("HELLO_Zoe!!", false);
// Load level
level1_groupbox.Visible = true;
}
private void close_btn_Click(object sender, EventArgs e)
{
this.Close();
}
private void Apply_btn_Click(object sender, EventArgs e)
{
// Get values
int br = Convert.ToInt32(breadth_box.Text.Trim());
int th = Convert.ToInt32(thickness_box.Text.Trim());
// Update part
nErrs1 = theSession.UpdateManager.DoUpdate(Id2);
// Load Bitmap Images
if (br == 25 && th == 6)
{
//Change Image Message
MessageBox.Image = Image.FromFile("");
MessageBox2.Image = Image.FromFile("");
}
else
{
//Change Image Message
MessageBox.Image = Image.FromFile("");
MessageBox2.Image = Image.FromFile("");
}
}
private void breadth_box_TextChanged(object sender, EventArgs e)
{
theSession.Parts.Work.Expressions.Edit(breadthExp, this.breadth_box.Text);
}
private void thickness_box_TextChanged(object sender, EventArgs e)
{
theSession.Parts.Work.Expressions.Edit(thicknessExp, this.thickness_box.Text);
}
}
}
RE: Window Forms in NXOpen
You may have to sign up for a free account to view it.
I've not (yet) had a need to create new threads, so I won't be of much help there. However, I know there are a few members here that might be able to help; hopefully they will jump in the discussion and teach us something.
www.nxjournaling.com
RE: Window Forms in NXOpen
I was wondering if any of the members have load two window forms in NX at the same time.
My code loads and shows both forms but then produces and error ufsr. The log file is not very helpful for identifying and fixing the problem.
Thanks in advance
Z.