UI styler and journal programing
UI styler and journal programing
(OP)
Hello,
I made a simple UI and want to control 2 parameters in the expression list with it.
Im not so familiar with journal more than recording and changing values so if someone could help it would be great!
When i do a recording changing the values it looks like this
' NX 9.0.0.19
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Tools->Expressions...
' ----------------------------------------------
theSession.Preferences.Modeling.UpdatePending = False
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression")
Dim expression1 As Expression = CType(workPart.Expressions.FindObject("Stalldon_Kort"), Expression)
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
workPart.Expressions.EditWithUnits(expression1, unit1, "100")
Dim expression2 As Expression = CType(workPart.Expressions.FindObject("Stalldon_lang"), Expression)
workPart.Expressions.EditWithUnits(expression2, unit1, "200")
theSession.Preferences.Modeling.UpdatePending = False
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
I made a simple UI and want to control 2 parameters in the expression list with it.
Im not so familiar with journal more than recording and changing values so if someone could help it would be great!
When i do a recording changing the values it looks like this
' NX 9.0.0.19
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Tools->Expressions...
' ----------------------------------------------
theSession.Preferences.Modeling.UpdatePending = False
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression")
Dim expression1 As Expression = CType(workPart.Expressions.FindObject("Stalldon_Kort"), Expression)
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
workPart.Expressions.EditWithUnits(expression1, unit1, "100")
Dim expression2 As Expression = CType(workPart.Expressions.FindObject("Stalldon_lang"), Expression)
workPart.Expressions.EditWithUnits(expression2, unit1, "200")
theSession.Preferences.Modeling.UpdatePending = False
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module





RE: UI styler and journal programing
In your VB code you will find a function called "update_cb" and it looks like this:
CODE --> VB
'------------------------------------------------------------------------------ 'Callback Name: update_cb '------------------------------------------------------------------------------ Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer Try If block Is Lyft Then '---- Enter your code here ----- ElseIf block Is Vipp 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 FunctionUsing the code in your recorded journal between the "Menu: Tools->Expressions..." and "Menu: Tools->Journal->Stop Recording" as a template, create the code to update the required expressions when each block changes.
Graham Inchley, Systems Developer.
NX6, NX8.5(testing)
www.sandvik.com