×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

problem when special char in journal > vb.net and Blockstyler

problem when special char in journal > vb.net and Blockstyler

problem when special char in journal > vb.net and Blockstyler

(OP)
hi
I'm a little challenged regarding a program I'm doing these weeks....NXOpen API
It's about the special char ....

A. I need to be able to set a string(which contains this ∆ (triangle)) in a cell in a tabNote....
I tried in NX8.5...in this case the is changed to ? or # , when set from journal..
I also tried in NX10....then nothing where set - just an error...see attach pic
I both NX 8.5 and NX 10 - it's possible to output a in a msgbox from a journal...but not in a tabNote cell....
It's also possible to manuel paste a ∆ into a cell in a tabNote.....

here is small code...(remember "name_of_tabNote")

CODE -->

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module test_my_triangle

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

    Sub Main()
        Dim theTabNoteTag As Tag
        theTabNoteTag = Find_TabNote_of_Given_Name("name_of_tabNote")
        If theTabNoteTag = Tag.Null Then Return
        '===========================================================================

        ' test A
        msgbox("Δ") ' works

        ' test B
        Set_theTabnote_Cell_Text(theTabNoteTag, 1, 0, "∆") 'do not work
        ' test C
        Set_theTabnote_Cell_Text(theTabNoteTag, 2, 0, "Δ") 'do not work

        '===========================================================================

    End Sub

    Public Function Find_TabNote_of_Given_Name(ByVal name As String) As Tag
        Dim tempTag As Tag = Tag.Null
        Dim tabNoteTag As Tag = Tag.Null
        Dim theDispPart As Part = theSession.Parts.Display
        Dim type, subType As Integer
        Do
            theUfSession.Obj.CycleByNameAndType(theDispPart.Tag, name, UFConstants.UF_tabular_note_type, False, tempTag)
            If tempTag = NXOpen.Tag.Null Then
                Continue Do
            End If
            theUfSession.Obj.AskTypeAndSubtype(tempTag, type, subType)
            If subType = UFConstants.UF_tabular_note_section_subtype Then
                theUfSession.Tabnot.AskTabularNoteOfSection(tempTag, tabNoteTag)
                Return tabNoteTag
            End If
        Loop Until tempTag = NXOpen.Tag.Null ' No more tabular notes are found
        Return Tag.Null
    End Function
    Public Sub Set_theTabnote_Cell_Text(ByVal tabular_note As Tag, ByVal rowIndex As Integer, _
         ByVal colIndex As Integer, ByVal newText As String)
        Dim row As NXOpen.Tag
        Dim col As NXOpen.Tag
        Dim cell As NXOpen.Tag

        theUfSession.Tabnot.AskNthRow(tabular_note, rowIndex, row)
        theUfSession.Tabnot.AskNthColumn(tabular_note, colIndex, col)
        theUfSession.Tabnot.AskCellAtRowCol(row, col, cell)
        theUfSession.Tabnot.SetCellText(cell, newText)

    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module 

B. I also tried to use a in Blockstyler..
In NX 8.5 when the is used in a text in a Radio button > output in dialog is a #
But in NX 10 this works as expected...see pic...

I will look forward, if anyone have some suggestions...

lklo

RE: problem when special char in journal > vb.net and Blockstyler

NX 10 is (iirc) the first version to have full unicode support. Make sure the "journal file format" preference is set to one of the unicode variants (find one that works for you). You may need to set a similar preference in your code editor as well.

www.nxjournaling.com

RE: problem when special char in journal > vb.net and Blockstyler

(OP)
Hi Cowski -
thanks a lot for your reply...

A. Yeahh , seems like that Blockstyler dialog's in NX 10 have unicode support...
B.. Regarding my vb code - I found the trick...
Maybe you'll find it usefull...
Here it comes:
ufs.Text.SetTextMode(UFText.ModeS.AllUtf8) 'enums: AllUtf8,Utf8 or Locale

Now I can simply put in my triangle directly in the code...

CODE -->

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module test_my_triangle

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Sub Main()
        Dim theTabNoteTag As Tag
        theTabNoteTag = Find_TabNote_of_Given_Name("name_of_tabNote")
        If theTabNoteTag = Tag.Null Then Return
        '===========================================================================
        ufs.Text.SetTextMode(UFText.ModeS.AllUtf8) ' here is the trick
        Dim str As String = "Δ"
        ' test B
        Set_theTabnote_Cell_Text(theTabNoteTag, 1, 1, str) 'do now work

        '===========================================================================

    End Sub
        Public Function Find_TabNote_of_Given_Name(ByVal name As String) As Tag
        Dim tempTag As Tag = Tag.Null
        Dim tabNoteTag As Tag = Tag.Null
        Dim theDispPart As Part = theSession.Parts.Display
        Dim type, subType As Integer
        Do
            theUfSession.Obj.CycleByNameAndType(theDispPart.Tag, name, UFConstants.UF_tabular_note_type, False, tempTag)
            If tempTag = NXOpen.Tag.Null Then
                Continue Do
            End If
            theUfSession.Obj.AskTypeAndSubtype(tempTag, type, subType)
            If subType = UFConstants.UF_tabular_note_section_subtype Then
                theUfSession.Tabnot.AskTabularNoteOfSection(tempTag, tabNoteTag)
                Return tabNoteTag
            End If
        Loop Until tempTag = NXOpen.Tag.Null ' No more tabular notes are found
        Return Tag.Null
    End Function
    Public Sub Set_theTabnote_Cell_Text(ByVal tabular_note As Tag, ByVal rowIndex As Integer, _
         ByVal colIndex As Integer, ByVal newText As String)
        Dim row As NXOpen.Tag
        Dim col As NXOpen.Tag
        Dim cell As NXOpen.Tag

        theUfSession.Tabnot.AskNthRow(tabular_note, rowIndex, row)
        theUfSession.Tabnot.AskNthColumn(tabular_note, colIndex, col)
        theUfSession.Tabnot.AskCellAtRowCol(row, col, cell)
        theUfSession.Tabnot.SetCellText(cell, newText)

    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module 

lklo

RE: problem when special char in journal > vb.net and Blockstyler

(OP)
Hi again -
just a small update on code..
Now I ask for original TextMode before changing - and the restore again when "cell writing" is done....

CODE -->

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module test_my_triangle

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Sub Main()
        Dim theTabNoteTag As Tag
        theTabNoteTag = Find_TabNote_of_Given_Name("name_of_tabNote")
        If theTabNoteTag = Tag.Null Then Return
        '===========================================================================
        Dim orignalTextMode As UFText.ModeS = ufs.Text.AskTextMode() 'rememeber
        Dim str As String = "Δ"
        ' test A
        ufs.Text.SetTextMode(UFText.ModeS.AllUtf8) ' set temporary yo Utf
        Set_theTabnote_Cell_Text(theTabNoteTag, 1, 1, str) 'do now work

        str = "lars" ' try comment out
        ' test B
        ufs.Text.SetTextMode(orignalTextMode) ' set back again to part original
        Set_theTabnote_Cell_Text(theTabNoteTag, 1, 2, str) 'now it fails again if str = "Δ" - as expected

        '===========================================================================

    End Sub
        Public Function Find_TabNote_of_Given_Name(ByVal name As String) As Tag
        Dim tempTag As Tag = Tag.Null
        Dim tabNoteTag As Tag = Tag.Null
        Dim theDispPart As Part = theSession.Parts.Display
        Dim type, subType As Integer
        Do
            theUfSession.Obj.CycleByNameAndType(theDispPart.Tag, name, UFConstants.UF_tabular_note_type, False, tempTag)
            If tempTag = NXOpen.Tag.Null Then
                Continue Do
            End If
            theUfSession.Obj.AskTypeAndSubtype(tempTag, type, subType)
            If subType = UFConstants.UF_tabular_note_section_subtype Then
                theUfSession.Tabnot.AskTabularNoteOfSection(tempTag, tabNoteTag)
                Return tabNoteTag
            End If
        Loop Until tempTag = NXOpen.Tag.Null ' No more tabular notes are found
        Return Tag.Null
    End Function
    Public Sub Set_theTabnote_Cell_Text(ByVal tabular_note As Tag, ByVal rowIndex As Integer, _
         ByVal colIndex As Integer, ByVal newText As String)
        Dim row As NXOpen.Tag
        Dim col As NXOpen.Tag
        Dim cell As NXOpen.Tag

        theUfSession.Tabnot.AskNthRow(tabular_note, rowIndex, row)
        theUfSession.Tabnot.AskNthColumn(tabular_note, colIndex, col)
        theUfSession.Tabnot.AskCellAtRowCol(row, col, cell)
        theUfSession.Tabnot.SetCellText(cell, newText)

    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources