Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal to edit a specific tabular note 1

Status
Not open for further replies.

SethKlain

Automotive
Jul 25, 2016
2
Hi All,

I am quite new to journaling using VB in NX 9.0.3, and I'm trying to programatically edit cells in a tabular note without user interaction.
I think I know the tag of the table that I want to edit but I could use some help figuring out how to refer to it please.
Here'a a sample of what I'm trying to do. Is this even the right way to go about this?

Code:
Dim nxopenSession As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim tabular_note_section As NXOpen.Tag
Dim tabular_note As NXOpen.Tag
Dim row As NXOpen.Tag
Dim col As NXOpen.Tag
Dim cell As NXOpen.Tag

'im sure this is part of the problem
 tabular_note.Value = 38275

nxopenSession.Tabnot.AskNthRow(tabular_note, 0, row)
nxopenSession.Tabnot.AskNthColumn(tabular_note, 2, col)
nxopenSession.Tabnot.AskCellAtRowCol(row, col, cell)
nxopenSession.Tabnot.SetCellText(cell, "predefined text to apply to cell")

Any help would be greatly appreciated.
Thanks!
 
Replies continue below

Recommended for you

You should apply a name to your tabular note. Then it will be easy to find and make the changes. Below is the code.

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1


    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    '  Explicit Activation
    '      This entry point is used to activate the application explicitly
    Sub Main()

        Dim theTabNoteTag As Tag

        theTabNoteTag = Find_TabNote_of_Given_Name("YourTabnoteName")

        If theTabNoteTag = Tag.Null Then Return

        Set_theTabnote_Cell_Text(theTabNoteTag, 0, 2, "predefined text to apply to cell")

    End Sub


    Public Function Find_TabNote_of_Given_Name(ByVal name As String) As Tag
        Dim tempTag As Tag = Tag.Null
        Dim tabNoteTag As Tag = Tag.Null

        Dim theDispPart As Part = theSession.Parts.Display
        Dim type, subType As Integer

        Do

            theUfSession.Obj.CycleByNameAndType(theDispPart.Tag, name, UFConstants.UF_tabular_note_type, False, tempTag)
            If tempTag = NXOpen.Tag.Null Then
                Continue Do
            End If

            theUfSession.Obj.AskTypeAndSubtype(tempTag, type, subType)

            If subType = UFConstants.UF_tabular_note_section_subtype Then
                theUfSession.Tabnot.AskTabularNoteOfSection(tempTag, tabNoteTag)
                Return tabNoteTag
            End If

        Loop Until tempTag = NXOpen.Tag.Null ' No more tabular notes are found

        Return Tag.Null

    End Function


    Public Sub Set_theTabnote_Cell_Text(ByVal tabular_note As Tag, ByVal rowIndex As Integer, _
                                  ByVal colIndex As Integer, ByVal newText As String)
        Dim row As NXOpen.Tag
        Dim col As NXOpen.Tag
        Dim cell As NXOpen.Tag

        theUfSession.Tabnot.AskNthRow(tabular_note, rowIndex, row)
        theUfSession.Tabnot.AskNthColumn(tabular_note, colIndex, col)
        theUfSession.Tabnot.AskCellAtRowCol(row, col, cell)
        theUfSession.Tabnot.SetCellText(cell, newText)

    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

End Module

Suresh
 
Thanks! That's a great idea.
I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor