Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

UI styler and journal programing

Status
Not open for further replies.

elletheman

Mechanical
Joined
Aug 22, 2014
Messages
1
Location
SE
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
 
Hi.
In your VB code you will find a function called "update_cb" and it looks like this:
Code:
'------------------------------------------------------------------------------
'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 Function
The way it works is when the user changes a value on your dialog the update_cb will be executed. Then the If statement will decide which block it was that was changed. You need to then supply the code to execute when that block was changed (where the ---- Enter your code here ---- comments are).
Using 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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top