Tabular Cell - Border settings -

H all,

I am looking for a Journal, due to my lack of programming knowledge I am posting it here in this Forum.
So here is the description of what I do now in NX1899.

I select a Cell of a Tabular note.
I select the Settings of that Cell.
I go to to the Common Tab.
And I make (for example) the Left Side Border: Invisible

I am sure this is something simple to be done by a Journal, but I do not succeed in it.
Anybody can give it a try and would like to share it here?

Best regards.
P.

http://nxjournaling.com/comment/861#comment-861

The code in the link above changes the font in each table cell. The process for changing the border lines would be similar:
- get the current cell preferences
- change the desired options in the cell preferences structure
- set the cell preferences to the updated structure

Dear Cowski,

thanks for your quick response, but unfortunately, this changes all cell.
I am particularly looking to modify only a call as in this case 1 cell only.

I have modified a Code I have to modify some Selected Dimensions, and I try to change this to modify a Cell Style:
But off course I do not succeed in it...

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpenUI
Imports System.Windows.Forms 'for key commands "{ESC}"

Module DimensionTextSize

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI
Dim workPart As Part = theSession.Parts.Work

If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If

'preselected objects
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim theComps As New List(Of Annotations.Table)

For i As Integer = 0 To numsel - 1
Dim selObj As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
If TypeOf (selObj) Is Annotations.Table Then
theComps.Add(selObj)
End If
Next

If theComps.Count = 0 Then
'no components found among the preselected objects
Return
End If

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Cell")

'for loop with declaration
Dim editSettingsBuilder1 As Annotations.EditSettingsBuilder
Dim editTableCell(0) As DisplayableObject
Dim nXObject1 As NXObject

For Each TableCell1 As TaggedObject In theComps
editTableCell(0) = TableCell1
editSettingsBuilder1 = workPart.SettingsManager.CreateTableEditSettingsBuilder(editTableCell1)
EditSettingsBuilder1.TableCellStyleBuilderBorderLocationType.Top = 0
nXObject1 = editSettingsBuilder1.Commit()
editSettingsBuilder1.Destroy()
'editDimension1(0).Unhighlight 'does not work properly, send "{ESC}" key instead
Next

'deselect all
SendKeys.SendWait("{ESC}")

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function

End Module

Do you think you can make this one working to modify a selected cell only?

Ok, I thought the issue was changing the cell preferences; but it looks like the issue is working with pre-selected objects. Try the code below:

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF

Module change_preselected_cell

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim theUI As UI = UI.GetUI

Sub Main()

If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Const undoMarkName As String = "NXJ change tabular note cell"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

'preselected objects, look for tabular note cell objects
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim theCells As New List(Of DisplayableObject)

For i As Integer = 0 To numsel - 1
Dim selObj As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
Dim objType As Integer
Dim objSubType As Integer
theUfSession.Obj.AskTypeAndSubtype(selObj.Tag, objType, objSubType)
If objType = UFConstants.UF_parametric_text_type AndAlso objSubType = UFConstants.UF_tabular_note_cell_subtype Then
theCells.Add(selObj)
End If
Next

For Each selCell As DisplayableObject In theCells
'get the current cell preferences
Dim theCellPrefs As UFTabnot.CellPrefs
theUfSession.Tabnot.AskCellPrefs(selCell.Tag, theCellPrefs)

'change the desired cell preference setting(s)
theCellPrefs.text_color = 186 'red in the default CDF, make sure drawing is not in monochrome mode
theCellPrefs.text_height = theCellPrefs.text_height * 2

'apply the new settings to the cell
theUfSession.Tabnot.SetCellPrefs(selCell.Tag, theCellPrefs)

Next

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module