Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NXOpen - Find note that resides in a drawing sheet

Status
Not open for further replies.

apekas

Automotive
Aug 15, 2005
36
NX 8.0.3 and NXOpen with VB.Net

I have a drawing part that has five drawing sheets and each sheet has a note named "Supplier_Number".

how can I find the note named "Supplier_Number" that resides in a specific drawing sheet, like sheet2 ?
 
Replies continue below

Recommended for you

The small journal will ask for the note text that you want to find. It then list the sheet/view name and the text you are looking for. Please not it only looks for simple notes and not for labels or PMI data. It also assumes that what you are looking for is not a word in multiple line note. All these are possible but not included in this simple journal. Hope it is of some help.

Regards

Frank Swinkels

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations

Module GetWordInfo
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = s.ListingWindow

    Sub Main()
        Dim dp As Part = s.Parts.Display
        Dim nc As NoteCollection = dp.Notes
        Dim textin As String = "text to find"
        Try
            textin = NXInputBox.GetInputString("Get Note Info", "Text to Find", textin)
        Catch ex As Exception
            GoTo end1
        End Try
        Dim dwgs As Drawings.DrawingSheetCollection
        dwgs = dp.DrawingSheets
        Dim notestring() As String
        lw.Open()
        For Each sheet As Drawings.DrawingSheet In dwgs
            sheet.Open()
            For Each a_note As Note In nc
                notestring = a_note.GetText()
                If notestring(0) = textin Then
                    lw.WriteLine(sheet.Name & "  ,  " & notestring(0))
                End If
            Next
        Next
end1:
    End Sub

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module
 
Hi Frank,

Thank you for your example. Unfortunately is not what I'm looking for.
Here is an example part. [URL unfurl="true"]http://files.engineering.com/getfile.aspx?folder=64310a39-28cb-4144-8dea-7905ecc589af&file=model1.prt[/url]
If I change the journal to search for the text in the second line, and I input "222", the results in the listing window list all the sheets, but the note with "222" it's only on Sheet 2.

When you do "Information Object" on a note, you get information on where it resides (see attached example)
[URL unfurl="true"]http://files.engineering.com/getfile.aspx?folder=4e15629d-46ff-43f3-8ff1-d3d1550a5b89&file=model1_note_info.txt[/url]
I don't know if it's posible to obtain that info with NXOpen.

Thanks
 
OK here is another journal. I now cycle through the drawing sheets. Then I get displayable objects on that sheet. Finally we search through the note text to find the text. Let me know how that goes.

Regards

Frank Swinkels

Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
Imports NXOpen.Drawings

Module GetWordInfo
    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = s.ListingWindow
    Dim dp As Part = s.Parts.Display
    Dim wp As Part = s.Parts.Work

    Sub Main()
        Dim nc As NoteCollection = dp.Notes
        Dim textin As String = "text to find"
        Dim cnt1 As Integer = Nothing
        Try
            textin = NXInputBox.GetInputString("Get Note Info", "Text to Find", textin)
        Catch ex As Exception
            GoTo end1
        End Try
        Dim dwgs As Drawings.DrawingSheetCollection = wp.DrawingSheets
        dwgs = wp.DrawingSheets
        Dim notestring() As String
        Dim viewtag As Tag = Tag.Null
        Dim dc As DrawingSheetCollection = dp.DrawingSheets
        lw.Open()
        For Each sheet As DrawingSheet In dc
            sheet.Open()
            Dim objs() As DisplayableObject = sheet.View.AskVisibleObjects()
            For Each obj As DisplayableObject In objs
                Dim a_Note As Note = CType(obj, Note)
                notestring = a_Note.GetText()
                Dim nolines As Integer = notestring.Length
                Dim found1 As Boolean = False
                For i As Integer = 0 To nolines - 1
                    found1 = notestring(i).Contains(textin)
                    If found1 = True Then
                        lw.WriteLine(sheet.Name)
                        For j As Integer = 0 To nolines - 1
                            lw.WriteLine("   " & notestring(j))
                        Next
                    End If
                Next
            Next
        Next
end1:
    End Sub
    
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module
 
Frank,

Thank you for the new journal.
I will take a look at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor