Submitted by dwang953 on Thu, 06/18/2015 - 11:56
Forums:
I am trying to extract the notes out an engineering drawing but am having trouble access all of the text within a note.
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
When I use the above code on the note below, I only get the first line "1 This is note 1"
1 This is note 1
2 This is note 2
3 This is note 3
re: note text
The .GetEditorText method returns a string array, each string in the array is a line of text in the note. If you want all the text in one Excel cell, you will need to combine the string array into a single string; the String.Join method is good for this
http://www.dotnetperls.com/join-vbnet
If you only want to read the note text, you do not need to use the drafting note builder. You can get the text directly from the note object. This will eliminate the need to create the drafting note builder each time through the loop and should make the code run faster.
For Each myNote as Annotations.Note in workPart.Notes
dim noteText() as String = myNote.GetText
'do something with noteText
Next
Note: the .GetText method also returns an array of string values even if there is only a single line of text in the note (as does the .GetEditorText method of the drafting note builder).
Thanks! I got the correct
Thanks! I got the correct output I needed, but I'm also getting a bunch of other "notes" that I don't want, such as detail labels or section labels, and even the numbers and letters on the edge of the drawing that define zones. Do you know how I can selectively output true text notes?
re: filter notes
I have two ideas for filtering out the zone identifiers:
1) Ignore notes that are only one or two letters long
2) Query the sheet size and border width, then look at the origin of each note; ignore notes that are in the border
For view and section labels, they contain references to attributes; if the note contains the text "@VWLETTER_DISP" (or other identifying text), ignore the note, it is a label.