×
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

NXOpen - Find note that resides in a drawing sheet

NXOpen - Find note that resides in a drawing sheet

NXOpen - Find note that resides in a drawing sheet

(OP)
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 ?

RE: NXOpen - Find note that resides in a drawing sheet

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 

RE: NXOpen - Find note that resides in a drawing sheet

(OP)
Hi Frank,

Thank you for your example. Unfortunately is not what I'm looking for.
Here is an example part. http://files.engineering.com/getfile.aspx?folder=64310a39-28cb-4144-8dea-7905ecc589af&file=model1.prt
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)
http://files.engineering.com/getfile.aspx?folder=4e15629d-46ff-43f3-8ff1-d3d1550a5b89&file=model1_note_info.txt
I don't know if it's posible to obtain that info with NXOpen.

Thanks

RE: NXOpen - Find note that resides in a drawing sheet

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 

RE: NXOpen - Find note that resides in a drawing sheet

(OP)
Frank,

Thank you for the new journal.
I will take a look at it.

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