Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Hello All, I have created some v 1

Status
Not open for further replies.

bhavyarani

Mechanical
May 2, 2015
11
0
0
IN
Hello All,

I have created some vb scripts using Visual Studio 2019 and NX is installed in same machine. Dll or Exe runs fine.
Same dll or exe if I share to other machines and test in NX it is not working.
I guess something to do with Setting. Can someone help me on this.


nx_l60nth.png
nx1_qru6hu.png

Code for reference:
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.Annotations


Public Class NXOpenWinForm
Dim nx As Session
Dim nxpart As Part
Dim nxUI As UI
Dim nxexpressions As ExpressionCollection
Dim nxexpression As Expression
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = Session.LibraryUnloadOption.Immediately
End Function
Private Sub NXOpenWinForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
nx = Session.GetSession()
nxUI = UI.GetUI()
nxpart = nx.Parts.Work
nxexpressions = nxpart.Expressions
nxexpression = nxpart.FindObject("Length")
TextBox1.Text = nxexpression.Value

nxexpression = nxpart.FindObject("Width")
TextBox2.Text = nxexpression.Value

nxexpression = nxpart.FindObject("Height")
TextBox3.Text = nxexpression.Value
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
nxexpression = nxpart.FindObject("Length")
nxexpressions.Edit(nxexpression, TextBox1.Text)

nxexpression = nxpart.FindObject("Width")
nxexpressions.Edit(nxexpression, TextBox2.Text)

nxexpression = nxpart.FindObject("Height")
nxexpressions.Edit(nxexpression, TextBox3.Text)

Dim umID As Session.UndoMarkId = Nothing
nx.UpdateManager.DoUpdate(umID)
End Sub
End Class
 
Replies continue below

Recommended for you

I suspect that the NX part file that you are working with is missing one or more of the "Length", "Width", or "Height" expressions. You need to add code to test for and handle this eventuality. This article is about querying existing expressions, near the end there is a section called "Finding an expression with a given name". It has a "try catch" block to handle errors when finding a given expression. This code might be a good starting point for your issue.

www.nxjournaling.com
 
Status
Not open for further replies.
Back
Top