Without seeing your actual code, it will be difficult to diagnose. Feel free to post your code or email it to info@nxjournaling.com. If you email it, please attach it as a .txt file; my email provider is very suspicious of .vb attachments and won't let them through.
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theSession As Session = Session.GetSession()
Dim theufsess As UFSession = UFSession.GetUFSession
Dim wprt As Part = theSession.Parts.Work
Dim prtlod As PartLoadStatus
wprt = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\Administrator\Desktop\blck1.prt", prtlod)
Dim exp1 As Expression = CType(wprt.Expressions.FindObject("hei"), Expression)
Dim null As Unit
Dim exp2 As Expression = CType(wprt.Expressions.FindObject("len"), Expression)
wprt.Expressions.EditWithUnits(exp2, null, TextBox2.Text)
Dim int1 As String = CStr(cal_ext(exp1, exp2))
Dim exp4 As Expression = CType(wprt.Expressions.FindObject("ext"), Expression)
wprt.Expressions.EditWithUnits(exp4, null, int1)
Dim int2 As Double = exp4.Value
Dim point As Point3d = New Point3d(0, 0, int2)
wprt.Points.CreatePoint(point)
'point_prep(exp4, wprt)
'Dim undomrk As Session.UndoMarkId
'theSession.UpdateManager.DoUpdate(undomrk)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'----Other unload options-------
'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Function cal_ext(ByRef hei As Expression, ByRef len As Expression) As Integer
Dim exp3 As Integer
exp3 = (hei.Value + len.Value) / 2
Return exp3
End Function
'Sub point_prep(ByRef ext As Expression, ByRef exx As Part)
' Dim int2 As Double = ext.Value
' Dim point As Point3d = New Point3d(0, 0, int2)
' exx.Points.CreatePoint(point)
'End Sub
End Class
here i have defined session,wprt, when button is clicked. below i am replacing expression as textbox1.text in sub main(), it is showing refrence to non shared required object refrence
thanks
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Utilities
Imports form_sc.Form1
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim wprt As Part = theSession.Parts.Work
Dim prtlod As PartLoadStatus
wprt = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\Administrator\Desktop\blck1.prt", prtlod)
Dim exp1 As Expression = CType(wprt.Expressions.FindObject("hei"), Expression)
Dim null As Unit
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'----Other unload options-------
'Unloads the image when the NX session terminates
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'Unloads the image explicitly, via an unload dialog
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
re: error
Can you give any more information and possibly the code snippet where the error occurs?
My default template is like
My default template is like this
Module
Sub
Dim s as session= session.getsession
Now I add form & some button which controls my expressions
I need to control expressions here via button
Wprt.expressions.findobject
Wprt.expressions.editwithunits(exp1,null,textbox1text)
I am avoiding code in
Public sub textbox1_textchanged(byval,byval)handles textbox1.textchanged
End sub
re: error
In the snippet above, Wprt is not defined and the .FindObject method needs input.
Since I was not getting my
Since I was not getting my module, thats why I have typed above, I have done all the stuff you are saying
I just want to control that string required in wprt.expressions.editwithunits that 3 rd argument with textbox in sub main()
actual code
Without seeing your actual code, it will be difficult to diagnose. Feel free to post your code or email it to info@nxjournaling.com. If you email it, please attach it as a .txt file; my email provider is very suspicious of .vb attachments and won't let them through.
Imports System
Imports System
Imports NXOpen
Imports NXOpen.Utilities
Imports System.Math
Imports NXOpen.MathUtils
Imports NXOpen.UF
Public Class Form1
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theSession As Session = Session.GetSession()
Dim theufsess As UFSession = UFSession.GetUFSession
Dim wprt As Part = theSession.Parts.Work
Dim prtlod As PartLoadStatus
wprt = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\Administrator\Desktop\blck1.prt", prtlod)
Dim exp1 As Expression = CType(wprt.Expressions.FindObject("hei"), Expression)
Dim null As Unit
wprt.Expressions.EditWithUnits(exp1, null, TextBox1.Text)
Dim exp2 As Expression = CType(wprt.Expressions.FindObject("len"), Expression)
wprt.Expressions.EditWithUnits(exp2, null, TextBox2.Text)
Dim int1 As String = CStr(cal_ext(exp1, exp2))
Dim exp4 As Expression = CType(wprt.Expressions.FindObject("ext"), Expression)
wprt.Expressions.EditWithUnits(exp4, null, int1)
Dim int2 As Double = exp4.Value
Dim point As Point3d = New Point3d(0, 0, int2)
wprt.Points.CreatePoint(point)
'point_prep(exp4, wprt)
'Dim undomrk As Session.UndoMarkId
'theSession.UpdateManager.DoUpdate(undomrk)
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'----Other unload options-------
'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Function cal_ext(ByRef hei As Expression, ByRef len As Expression) As Integer
Dim exp3 As Integer
exp3 = (hei.Value + len.Value) / 2
Return exp3
End Function
'Sub point_prep(ByRef ext As Expression, ByRef exx As Part)
' Dim int2 As Double = ext.Value
' Dim point As Point3d = New Point3d(0, 0, int2)
' exx.Points.CreatePoint(point)
'End Sub
End Class
here i have defined session,wprt, when button is clicked. below i am replacing expression as textbox1.text in sub main(), it is showing refrence to non shared required object refrence
thanks
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Utilities
Imports form_sc.Form1
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim wprt As Part = theSession.Parts.Work
Dim prtlod As PartLoadStatus
wprt = theSession.Parts.OpenBaseDisplay("C:\Documents and Settings\Administrator\Desktop\blck1.prt", prtlod)
Dim exp1 As Expression = CType(wprt.Expressions.FindObject("hei"), Expression)
Dim null As Unit
wprt.Expressions.EditWithUnits(exp1, null, textbox1.text)
End Sub
'TODO: Add your application code here
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
'----Other unload options-------
'Unloads the image when the NX session terminates
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'Unloads the image explicitly, via an unload dialog
' GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module
re: expression values on form
The code in the 2nd post of
http://www.eng-tips.com/viewthread.cfm?qid=328251
may be of some interest to you. I don't think it does exactly what you want, but it may be a starting point.
Thanks it's working gr8 for
Thanks it's working gr8 for me