Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

what's the correct synax to loop through each tabular notes on drawing

Status
Not open for further replies.

godpaul

Automotive
Joined
May 4, 2014
Messages
119
Location
US
i try to identify the name of each tabular note table on drawing, so i find the following and try to add the last two lines:

'edit tab note cell text revised by me
Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports System.Windows.Forms
Imports System.Environment

Module find_name_of_tabular
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()
Dim displayPart As Part = theSession.Parts.Display
lw.Open()

Dim workPartTag As NXOpen.Tag = displayPart.Tag

For Each tabularNote As NXOpen.Tag In workPartTag



error is: expression of nxopen.tag is not a collection of type

i just try to mimic the way i did for note which is: or Each theNote As Note In displayPart.Notes
but here it doesnt work.


what will be the correct way to state For...each....in ? thanks
 
The .net API has started adding support for tabular notes in recent versions, each version seems to add more functionality. If you are running NX 8 or above, you can access a collection of "Table" objects and "TableSection" objects with syntax that looks like:

Code:
myPart.Annotations.Tables
myPart.Annotations.TableSections

I've not done much work with them yet, you may want to check the GTAC solution center to see if there are any code snippets to help you.

Also, you can loop through the existing tabular notes with the UF functions. Some examples can be found here:

P.S. I would advise against using a variable named workPartTag to reference the tag of the display part. The work part and the display part may refer to the same part, but may refer to 2 separate parts.

www.nxjournaling.com
 
WOW, the tabular note is more complex than what i think here is what i learned:

the following codes are grabbed from GTAC


Dim nm_rows As Integer
Dim nm_cols As Integer
Dim tabular_note As NXOpen.Tag

'here, these two lines of codes will change the value of nm_cols and nm_rows nxopenSession.Tabnot.AskNmColumns(tabular_note, nm_cols)
nxopenSession.Tabnot.AskNmRows(tabular_note, nm_rows)
MessageBox.Show("Columns:" & nm_cols.ToString() & Newline _
& "Rows:" & nm_rows.ToString())

==================================================================================

'here, col and row is defined as Tag Dim row As NXOpen.Tag
Dim col As NXOpen.Tag
Dim cell As NXOpen.Tag

' the "row" and "col" has nothing to do with anythign but just stay there?
'the 0 and 0 are the actual index of the table!
nxopenSession.Tabnot.AskNthRow(tabular_note, 0, row)
nxopenSession.Tabnot.AskNthColumn(tabular_note, 0, col)

nxopenSession.Tabnot.AskCellAtRowCol(row, col, cell)
nxopenSession.Tabnot.SetCellText(cell, "Unrecyclable Styrofoam")






cowski, i borrowed your code which is the change of font code and i did the following tesing

or Each tableNote As Tag In myTabularNoteTags
'Dim tablenote As Tag

Dim title As String = "table"
Dim row As Tag
Dim col As Tag
Dim cell As Tag

theUfSession.Tabnot.AskNthRow(tableNote, 0, row)
theUfSession.Tabnot.AskNthColumn(tableNote, 0, col)
theUfSession.Tabnot.AskCellAtRowCol(row, col, cell)
theUfSession.Tabnot.SetCellText(cell, title)

Next





as you see, i revised your for loop JUST want to do what i plan to do, change some text in the cell!!!! It's successful!!



now the question now is i want to find out the name of the table, i searched the intellisense, but didnt get any luck

i doubt i has somethign to do with theUfSession.Tabnot.AskCellText
i guess if askcelltext returns a string matches with what i define in another string like "table 1"
then i can import data....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top