Extracting Title Block Information

Hello Again,

I'm slowly crawling towards the end of my first Journal. I have with your help managed to get a bit of code to locate the two tables I am interested in. Extracting the information from them is the next step, which I already have some start in.

That being said, I have stumbled upon a new problem. We use a template to start a drawing, so I thought the title block would be stored in the same location each time. So I made a journal and tried to just copy that location over. Here is the code.

Sub FindTitleBlockInformation(ByRef tagList As List(Of String))

'--------------------------------------
' Finds the title bocks in the sessions
'--------------------------------------

Dim titleblocks1(3) As Annotations.TitleBlock
Dim titleBlock1 As Annotations.TitleBlock = CType(workPart.FindObject("HANDLE R-147862"), Annotations.TitleBlock)

titleblocks1(0) = titleBlock1
Dim titleBlock2 As Annotations.TitleBlock = CType(workPart.FindObject("HANDLE R-169015"), Annotations.TitleBlock)

titleblocks1(1) = titleBlock2
Dim titleBlock3 As Annotations.TitleBlock = CType(workPart.FindObject("HANDLE R-197476"), Annotations.TitleBlock)

titleblocks1(2) = titleBlock3
Dim titleBlock4 As Annotations.TitleBlock = CType(workPart.FindObject("HANDLE R-393572"), Annotations.TitleBlock)

titleblocks1(3) = titleBlock4
Dim editTitleBlockBuilder1 As Annotations.EditTitleBlockBuilder
editTitleBlockBuilder1 = workPart.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder(titleblocks1)

Dim titleBlockCellBuilderList1 As Annotations.TitleBlockCellBuilderList
titleBlockCellBuilderList1 = editTitleBlockBuilder1.Cells

'--------------------------------------
' Finds the cells in the title blocks'
'--------------------------------------

Dim taggedObject1 As TaggedObject
taggedObject1 = titleBlockCellBuilderList1.FindItem(0)

Dim titleBlockCellBuilder1 As Annotations.TitleBlockCellBuilder = CType(taggedObject1, Annotations.TitleBlockCellBuilder)

Dim taggedObject2 As TaggedObject
taggedObject2 = titleBlockCellBuilderList1.FindItem(1)

Dim titleBlockCellBuilder2 As Annotations.TitleBlockCellBuilder = CType(taggedObject2, Annotations.TitleBlockCellBuilder)

Dim taggedObject3 As TaggedObject
taggedObject3 = titleBlockCellBuilderList1.FindItem(10)

Dim titleBlockCellBuilder3 As Annotations.TitleBlockCellBuilder = CType(taggedObject3, Annotations.TitleBlockCellBuilder)

Dim PIN As string
PIN = titleBlockCellBuilder1.EditableText

Dim INITIALS As string
INITIALS = titleBlockCellBuilder2.EditableText

Dim ImplantName As string
ImplantName = titleBlockCellBuilder3.EditableText

tagList.Add(PIN)
tagList.Add(INITIALS)
tagList.Add(ImplantName)

End Sub

But I then ran it in another drawing to test to make sure it would follow through, and as you can guess, it did not. So my question is, how do I access the information from the populate title block tool reliably? I know it will have the same structure each time (I.E the same 11 items in the same order) There will be multiple sheets with the same information possibly presented in a different format for the table, but still present. Any ideas? I'm going to go back to the docs to see if I'm missing something glaringly obvious.

Do the title block notes pull the information from part attributes by chance? From the nature of your question, I assume the answer is no; but this will be fairly easy if the answer is "yes".

Also, what version of NX?

Any luck so far? I have been running around in circles trying to get anything to locate them reliably.

We do not, we use populate title block and fill in the information manually.

We are using NX 8.5

Rather than using the .FindObject method to get the title blocks, I would suggest getting them directly from the part's annotation manager. Something like the code below:

Dim titleblocks1() As Annotations.TitleBlock = {part object}.DraftingManager.TitleBlocks.ToArray