×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

i try to find get the title of a attribute for a tabular note, but failed

i try to find get the title of a attribute for a tabular note, but failed

i try to find get the title of a attribute for a tabular note, but failed

(OP)
i first recorded the journal to see what code it will give to you if i try to modify the title of attribute. then i get the code and modify it with my understanding

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports System.Environment

Module replace_tabular_note_experiment

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As Part = theSession.Parts.Work
Dim theUI As UI = UI.GetUI()

Sub Main()

If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim myTabularNoteTags As New List(Of Tag)
If FindTabularNotes(myTabularNoteTags) = 0 Then
'no tabular notes to process
Return
End If


For Each tableNote As Tag In myTabularNoteTags

Dim obj(0) As NXObject
Dim tableSection As Annotations.TableSection = CType(workPart.Annotations.TableSections.FindObject("tableNote"), Annotations.TableSection)
obj(0) = tableSection
Dim attribute As AttributePropertiesBuilder
attribute = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, obj, AttributePropertiesBuilder.OperationType.None)
Dim titleName As String = attribute.Title

lw.WriteLine(titleName)
Exit Sub

Function FindTabularNotes(ByRef theTabNotes As List(Of Tag)) As Integer

Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
Dim type As Integer
Dim subtype As Integer

Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
If tmpTabNote = NXOpen.Tag.Null Then
Continue Do
End If
If tmpTabNote <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
If subtype = UFConstants.UF_tabular_note_subtype Then

theTabNotes.Add(tmpTabNote)

End If
End If
Loop Until tmpTabNote = NXOpen.Tag.Null

Return theTabNotes.Count

End Function




error is no objects is found with this name "tableNote". the "tableNote" is right click property general tab and revise the name there

RE: i try to find get the title of a attribute for a tabular note, but failed

(OP)
here is the only codes i came up with last night...... it works an no error BUT didnt return correct result
after the program runs, it returns Table 32434, whose digits can vary from session to session.......

CODE --> Basic

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Windows.Forms
Imports System.Collections.Generic
Imports System.Environment

Module replace_tabular_note_experiment

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession
    Dim workPart As Part = theSession.Parts.Work
    Dim theUI As UI = UI.GetUI()

    Sub Main()

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim myTabularNoteTags As New List(Of Tag)
        If FindTabularNotes(myTabularNoteTags) = 0 Then
            'no tabular notes to process
            Return
        End If

        ''get excel file ready
        'Dim objExcel = CreateObject("Excel.Application")
        'If objExcel Is Nothing Then
        '    MsgBox("Could not start Excel, this journal will now exit.", MsgBoxStyle.Critical, "Error")
        '    Exit Sub
        'End If
        ''excel file location
        'Dim excelFile As String = "k:\excelsheet.xlsx"
        'If Not IO.File.Exists(excelFile) Then
        '    MsgBox("Specified file not found, journal will now exit.", MsgBoxStyle.Critical, "File not found.")
        '    Exit Sub
        'End If
        ''open excel file
        'Dim objWorkbook = objExcel.Workbooks.Open(excelFile)
        'If objWorkbook Is Nothing Then
        '    MsgBox("Could not open Excel file, journal will now exit.", MsgBoxStyle.Critical, "Error")
        '    Exit Sub
        'End If

        Dim emptyStr As String = ""

        For Each tableNote As Tag In myTabularNoteTags
            Dim tableTitle As String
            Dim rowTag As Tag
            Dim colTag As Tag
            Dim cellTag As Tag
            'get the title info from the current table, not the best way, i want to get the property name...later
            theUfSession.Tabnot.AskNthRow(tableNote, 0, rowTag)
            theUfSession.Tabnot.AskNthColumn(tableNote, 0, colTag)
            theUfSession.Tabnot.AskCellAtRowCol(rowTag, colTag, cellTag)
            theUfSession.Tabnot.AskCellText(cellTag, tableTitle)

            Dim obj As NXObject
            obj = theUfSession.GetObjectManager.GetTaggedObject(tableNote)
            Dim ai As NXObject.AttributeInformation() = obj.GetUserAttributes
            lw.WriteLine(obj.ToString())
            lw.WriteLine(obj.Name)        Next
        lw.Close()

    End Sub

    Function FindTabularNotes(ByRef theTabNotes As List(Of Tag)) As Integer

        Dim tmpTabNote As NXOpen.Tag = NXOpen.Tag.Null
        Dim type As Integer
        Dim subtype As Integer

        Do
            theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTabNote)
            If tmpTabNote = NXOpen.Tag.Null Then
                Continue Do
            End If
            If tmpTabNote <> NXOpen.Tag.Null Then
                theUfSession.Obj.AskTypeAndSubtype(tmpTabNote, type, subtype)
                If subtype = UFConstants.UF_tabular_note_subtype Then

                    theTabNotes.Add(tmpTabNote)

                End If
            End If
        Loop Until tmpTabNote = NXOpen.Tag.Null

        Return theTabNotes.Count

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnAloadOption.Explicitly
        '-------------------------------

    End Function

End Module 

RE: i try to find get the title of a attribute for a tabular note, but failed

(OP)
i am exhausted....

so far, find two ways, one is get unique ID no of each table on drawing which is:

CODE -->

Dim ID As UInteger = 0
            Dim version As UInteger = 0
            Dim fileData As String = Nothing
            Dim handle As String = theUfSession.Tag.AskHandleOfTag(tableNote)
            theUfSession.Tag.DecomposeHandle(handle, fileData, ID, version)
            lw.WriteLine(ID) 

this return ID no. like 4892832 34324839 etc, etc, they really dont change from session to session, but too hard to handle....


another one is attributeproperty builder which is

CODE -->

Dim obj(0) As NXObject
            obj(0) = NXObjectManager.Get(tableNote)
            Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
            attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, obj, AttributePropertiesBuilder.OperationType.None)
            Dim str As String = attributePropertiesBuilder1.Title
            lw.WriteLine(str) 

however, this returns nothing..........


if you replace the code highilighed with bold font from the upper reply with the code here, you will see..

help needed..

here is the drawing fiel contains two tables and they have title and name in the attribute
http://files.engineering.com/getfile.aspx?folder=3...


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources