×
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

Export all notes to a text file or to the spreadsheet in NX9 Drafting

Export all notes to a text file or to the spreadsheet in NX9 Drafting

Export all notes to a text file or to the spreadsheet in NX9 Drafting

(OP)
Hi,

Application Drafting:
Is the an easy way to export all notes to a text file or to the spreadsheet in NX9 ?

I need this function to send the .txt or .xlsx for translation

TIA

Regards
Didier Psaltopoulos
http://www.psi-cad.com

RE: Export all notes to a text file or to the spreadsheet in NX9 Drafting

Try the following journal:

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUISession As UI = UI.GetUI
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim myDocs As String
        myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        Dim outputFile As String = IO.Path.Combine(myDocs, workPart.Leaf & "_notes.txt")
        If IO.File.Exists(outputFile) Then
            Try
                IO.File.Delete(outputFile)
            Catch ex As Exception
                lw.WriteLine("error deleting file: " & outputFile)
                Return
            End Try
        End If


        'pass False to overwrite existing file, True to append existing file
        'if file does not exist, a new file will be created and the True/False value will be ignored
        Using myWriter As New IO.StreamWriter(outputFile, True)

            For Each tempNote As Annotations.Note In workPart.Notes

                Dim noteLines() As String
                noteLines = tempNote.GetText

                For Each noteLine As String In noteLines
                    myWriter.WriteLine(noteLine)
                Next

                'leave blank line between notes
                myWriter.WriteLine("")

            Next

        End Using

        'lw.WriteLine("notes for NX part file: " & workPart.Leaf & " have been exported to: " & outputFile)
        Dim response As Integer
        Dim messages(3) As String
        messages(0) = "notes for NX part file: " & workPart.Leaf
        messages(1) = "Have been exported to: " & outputFile
        messages(2) = ""
        messages(3) = "Open file now?"

        response = theUISession.NXMessageBox.Show("Notes export complete", NXOpen.NXMessageBox.DialogType.Question, messages)
        '1 = Yes
        '2 = No

        If response = 1 Then
            System.Diagnostics.Process.Start(outputFile)
        End If

        lw.Close()

    End Sub


    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.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module 

www.nxjournaling.com

RE: Export all notes to a text file or to the spreadsheet in NX9 Drafting

(OP)
Hi Cowski

Thank you and I wish you an happy new year

Regards
Didier Psaltopoulos
http://www.psi-cad.com

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