Hello everyone,
I have written something to search out title blocks (in 8.5 and 10) and then I try to check which ones it is storing by using getcell to get the first cell in the title block and print it. It doesn't seem to be accessible though, which is weird. Is it because it doesn't see a titleblock as a table or am I doing something wrong. Here is my code. Please help if you can.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim theUISession As UI = UI.GetUI
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim tmpTitleBlock As NXOpen.Tag = NXOpen.Tag.Null
Dim tmpTitleBlockObj as displayableObject
Dim myTitleBlocks As New List(Of Tag)
Dim NxType As Integer
Dim NxSubtype As Integer
Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_tabular_note_type, tmpTitleBlock)
If tmpTitleBlock <> NXOpen.Tag.Null Then
theUfSession.Obj.AskTypeAndSubtype(tmpTitleBlock, NxType, NxSubtype)
If NxSubtype = UFConstants.UF_draft_title_block_subtype
try
tmpTitleBlockObj = NXOpen.Utilities.NXObjectManager.Get(tmpTitleBlock)
Dim cellText As String = ""
cellText = GetCell(tmpTitleBlock, 0, 0)
If workPart.Layers.GetState(tmpTitleBlockObj.Layer) <> Layer.State.Hidden Then
lw.WriteLine("The table being stored Contains " & cellText)
myTitleBlocks.Add(tmpTitleBlock)
End If
catch nxexc as nxexception
‘msgbox(nxexc.message)
end try
End If
End If
Loop Until tmpTitleBlock = NXOpen.Tag.Null
End Sub
End Module
re: tabular note text
Is "GetCell" a function that you have written? I don't see it defined anywhere in the code above.
http://nxjournaling.com/comment/678#comment-678
You will find code in the link above that will return the text in each cell of a tabular note. The code just loops over all the cells in the note, but you can modify it to return a specific cell if that is what you need.
Not what I was looking for
Hello,
Sorry I didnt explane myself well.
First, yes the getcell is a function I have written. I have forgotten to include the code, which could explain why it isnt working, I will try that.
But the problem I am finding currently is that in NX 10, the title block is not seen as a tabular note, and so the search I have is not finding it. I dont know why this is but it works fine in 8.5 then when I've tried in 10 it just misses the title blocks completely.
re: title blocks
Each part has a collection of title block objects that you can access.
{part ref}.DraftingManager.TitleBlocks
You should be able to access all of the title block objects from this collection.
Ok
So I found that information in the documentation. I have been trying to access it the following way.
Dim theSession As Session = Session.GetSession()
Dim theUISession As UI = UI.GetUI
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim DrftAppMngr As workPart.DraftingManager
Dim TtlBlkCol As TitleBlockCollection = DrftAppMngr.TitleBlocks
But for some reason, I keep getting the error that the drafting part manager is not defined.
These are all the imports I have in the script so far.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Drawings
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.Annotations
Imports NXOpen.Drafting
Im not sure what to make of this.
Kind regards,
Jelrae
The next question I have is
The next question I have is how do I create an edittitleblockbuilder for the titleblock collection? I tried the following:
Dim tmpString As String = workPart.DraftingManager.TitleBlocks.EditTitleBlockBuilder.GetCellValueForLabel("PIN")
But I cannot seem to get it to work.
re: edit title block builder
I've not used the edit title block builder object, but the syntax for other builders is to pass in the specific object that you want to edit with the builder.
Dim editTitleBlockBuilder1 as EditTitleBlockBuilder
editTitleBlockBuilder1 = theSession.Parts.Work.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder({myTitleBlock})
Ok so I did try that, but it
Ok so I did try that, but it wouldnt compile. I ended up having wo write it like this:
Dim TBC As TitleBlockCollection = workPart.DraftingManager.TitleBlocks
Dim TitleBlkArry() As TitleBlock = TBC.ToArray()
Dim ETBB As Annotations.EditTitleBlockBuilder = workPart.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder(TitleBlkArry)
What I dont understand is the following.
I tried to declare a variable in two lines
Dim ETBB As Annotations.EditTitleBlockBuilder = workPart.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder(TitleBlkArry)
I wanted that to be
Dim ETBB As Annotations.EditTitleBlockBuilder
ETBB = workPart.DraftingManager.TitleBlocks.CreateEditTitleBlockBuilder(TitleBlkArry)
Just because that was how it was shown in an example/
But it told me that in the second declaration (the one with ETBB = ) That the ETBB = ..... line was expecting a declaration. Isnt what I wrote after it a declaration. Why does it work when I put it on one line but not two?
re: CreateEditTitleBlockBuilder
I don't have a definitive answer as that depends on how the internal API functions were implemented. However, I suspect that when you declare the builder object it implicitly calls the "New" method of the builder and that method expects a title block to be passed in at that time (and not later).