Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX11 - Possible to Export Notes to Excel? 1

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
We have a file that only has a bunch of notes on the drafting side. Each note is a 5 digit number. Is it possible to select these notes and some how export them to an excel sheet?

Would anyone have a journal that can accomplish this?
 
Replies continue below

Recommended for you

thread561-376950

The code in the thread above will export all the notes to a text file. Open Excel and import the text file.

If this is something that you will be doing on a regular basis, you can modify the journal to output directly to Excel.

www.nxjournaling.com
 
Sorry I never replied cowski. I use to get emails when there were replies. I dont seem to lately so I never realize someone replied until I come back in to look.

I wish I would have seen this. lol I worked for days trying to figure it out. Finally I found some code where someone did what i needed with dimensions. So I spend a day trying to manipulate that to work with notes. I finally got it to work, but seeing this would have saved me a lot of hassle and time. lol

The good news is I am sure I must have learned a little more in doing it. lol This is the code I ended up with if you're interested. I am sure it could be cleaned up and made better. Once I even got it to work I wasnt messing with it. lol

How do you guys get your code to show up in a lighter background in these posts?




Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUISession As UI = UI.GetUI
Dim workPart As Part = theSession.Parts.Work

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

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "journal")

'change excelFileName to meet your needs
Const excelFileName As String = "S:\Buttons\Journals\test\Book2.xlsx"
Dim row As Long = 1
Dim column As Long = 1

'create Excel object
Dim objExcel = CreateObject("Excel.Application")
If objExcel Is Nothing Then
theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not start Excel, journal exiting")
theSession.UndoToMark(markId1, "journal")
Exit Sub
End If

'open Excel file
Dim objWorkbook = objExcel.Workbooks.Open(excelFileName)
If objWorkbook Is Nothing Then
theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not open Excel file: " & excelFileName & ControlChars.NewLine & "journal exiting.")
theSession.UndoToMark(markId1, "journal")
Exit Sub
End If

objExcel.visible = True

objExcel.Cells(row, 1) = workPart.FullPath

dim noteText() as String '= myNote.GetText
For Each myNote As Annotations.Note In workPart.Notes
row += 1
Dim draftingNoteBuilder As Annotations.DraftingNoteBuilder
draftingNoteBuilder = workPart.Annotations.CreateDraftingNoteBuilder(myNote)
objExcel.Cells(row, 1) = draftingNoteBuilder.Text.GetEditorText
Next

'objExcel.Quit()
objWorkbook = Nothing
objExcel = Nothing

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



Either way, I am going to give the code in the link you left a try as well. I appreciate the help.
 
Kenja824 said:
How do you guys get your code to show up in a lighter background in these posts?

Surround your code with code tags, like this:
[ignore]
Code:
Your code here
[/ignore]

This will show up as:
Code:
Your code here

To see the allowed tags, click the little question mark icon next to the preview button in the reply box.

www.nxjournaling.com
 
Cool, thanks.

Some reason I always thought the code button was to add html stuff to your post, though now that I look it doesnt make sense since these posts allow us to do all the formatting anyway. lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor