Submitted by Evgeny88 on Thu, 01/18/2018 - 05:27
Forums:
Hello!
I`m looking for text in tabular cells which is linked to expression (type string). There are any specific methods in NXOPEN how I can recognize which expression string was used in particular cell?
Now only comparison of the strings in expression and celltext comes to my mind. But this is not reliable, because link in tabular cell different from expression string value, and easily can be changed inside the cell by some another settings by user(scale, bold text and so on)
Could you share another ideas?
Thanks a lot in advance!
re: text in tabular cell
If you have a string expression named "test" and link its value to a tabular note cell, the resulting text of the tabular note cell will be "<X@test>" or "<X0.2@test>" (the "0.2" is used to format numerical values). To get the text as shown on the face of the drawing, you would need to use the .AskEvaluatedCellText method. Knowing this, you could use some string manipulation functions to search for the telltale signs that the text refers to an expression (the "<X*@*>" pattern) and extract the expression name from the text.
text in tabular cell
Thanks for this advice! This function makes code easier and more reliable. Because before that I used string comparison between expresssion name ( if string type) and link of expression inside the cell:
Public Shared Function initial_MP_NAME_2(ByVal celltext As String) As String
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim ui As UI = UI.GetUI()
Dim workPart As Part = s.Parts.Work
Dim letter As String = ""
Dim compared As Integer
For Each myexp As Expression In workPart.Expressions
If myexp.Type.ToLower = "string" Then
compared = InStr(celltext,myexp.Name)
If compared<>0 Then
celltext = myexp.StringValue
Exit For
End If
End If
Next
Dim pieceoftext As String = Mid(celltext,1,2)
For i As Integer = 1 To Len(pieceoftext)
Dim point As String = Mid(pieceoftext,i,1)
If Mid(pieceoftext,i,1) = "." Then
letter = Mid(celltext,1,1)
End If
Next
Return letter
End Function
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
But now I do like that - ask text in cell without filtering for string expressions
For irow As Integer=0 To numRows-1
Dim rowtag As Tag
theUfsession.Tabnot.AskNthRow(tabnote_1,irow,rowtag)
For jcol As Integer=0 To numCols-1
Dim coltag As Tag
theUfsession.Tabnot.AskNthColumn(tabnote_1,jcol,coltag)
Dim cellTag As Tag
theUfsession.Tabnot.AskCellAtRowCol(rowTag,colTag,cellTag)
theUfsession.Tabnot.AskEvaluatedCellText(cellTag,thecelltext)
next
next
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
thanks a lot!
thanks
E