ViewLabel name

Hello! could you please follow me where I can get ViewLabel name as string Value for the drawing views? Is there any differences of types between sectionview label and detail view for example?

I`ve tried to get the label of view as below, but thats return nothing:

Dim viewlabel As UFDraw.ViewLabelParms = New UFDraw.ViewLabelParms
Dim info As String = viewlabel.view_letter
lw.WriteLine("info: " & info)
'result info:

The code below shows how to get some information out of the view label. Post back with any specific questions that you have.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim ufSession As UFSession = ufSession.GetUFSession
        Dim lw As ListingWindow = theSession.ListingWindow
 
        lw.Open()
 
        Const undoMarkName As String = "view label size factor"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
 
 
        Dim validViewParms As Integer = -1
 
        For Each temp As Drawings.DraftingView In workPart.DraftingViews
 
            lw.WriteLine(temp.Name)
            'lw.WriteLine("view label shown: " & temp.Style.General.ViewLabel.ToString)
            'lw.WriteLine("scale label shown: " & temp.Style.General.ScaleLabel.ToString)
            'lw.WriteLine("")
 
            'if neither the view label nor scale label is shown, skip to next view
            If Not (temp.Style.General.ViewLabel Or temp.Style.General.ScaleLabel) Then
                Continue For
            End If
 
            Dim myLabel As UFDraw.ViewLabelParms = New UFDraw.ViewLabelParms
 
            Dim viewLabelTag As Tag
            ufSession.Draw.AskViewLabel(temp.Tag, viewLabelTag)
 
            Dim viewLabelObj As Annotations.Note = Utilities.NXObjectManager.Get(viewLabelTag)
            Dim noteText() As String = viewLabelObj.GetText
            lw.WriteLine("raw view label text:")
            For Each tempLine As String In noteText
                lw.WriteLine(tempLine)
            Next
            lw.WriteLine("")
 
            lw.WriteLine("evaluated label text:")
            Dim aT As Annotations.AssociativeText = theSession.Parts.Work.Annotations.CreateAssociativeText
            Dim cData As Annotations.ComponentData = theSession.Parts.Work.Annotations.CreateComponentData(viewLabelObj)
            For Each tC As Annotations.TextComponent In cData.GetTextComponents
                For Each aLine As String In tC.GetText
                    lw.WriteLine(aT.GetEvaluatedText(viewLabelObj, aLine))
                Next
            Next
            lw.WriteLine("")
 
            validViewParms = ufSession.Draw.AskViewLabelParms(viewLabelTag, myLabel)
 
            If validViewParms = UFConstants.UF_DRAW_invalid_parameter Then
                MsgBox("parameters could not be loaded for " & temp.Name)
                Continue For
            Else
                MsgBox("Name: " & temp.Name & vbCrLf & _
                       "parent type: " & myLabel.parent_label_type.ToString & vbCrLf & _
                       "type: " & myLabel.GetType.ToString & vbCrLf & _
                       "parm type: " & myLabel.view_label_parm_type.ToString & vbCrLf & _
                       "letter format: " & myLabel.letter_format.ToString & vbCrLf & _
                       "view letter: " & myLabel.view_letter)
 
            End If
            'MsgBox("UF_DRAW_invalid_parameter: " & UFConstants.UF_DRAW_invalid_parameter.ToString)
            'MsgBox("validViewParms: " & validViewParms.ToString)
            'MsgBox("old letter size factor: " & myLabel.letter_size_factor.ToString)
 
            myLabel.letter_size_factor = 1.6
            'myLabel.letter_format = UFDraw.ViewLabelLetterFormat.ViewLabelDashedLetter
 
            ufSession.Draw.SetViewLabelParms(viewLabelTag, myLabel)
 
        Next
 
    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

Thanks for that piece of code! Based of that, i`ve added function which is comparing input string and view name - if coinsident then return ViewLabel name string!

Public shared Function getViewLabel(Byref ViewName 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 lw As ListingWindow = s.ListingWindow
Dim validViewParms As Integer = -1
For Each tempView As DraftingView In workPart.DraftingViews
If Not (tempView.Style.General.ViewLabel Or tempView.Style.General.ScaleLabel) Then
Continue For
End If
If tempView.Name = ViewName Then
Dim myLabel As UFDraw.ViewLabelParms = New UFDraw.ViewLabelParms
Dim viewLabelTag As Tag
ufs.Draw.AskViewLabel(tempView.Tag, viewLabelTag)
Dim viewLabelObj As Annotations.Note = Utilities.NXObjectManager.Get(viewLabelTag)
lw.WriteLine("evaluated label text:")
Dim aT As Annotations.AssociativeText = workPart.Annotations.CreateAssociativeText
Dim cData As Annotations.ComponentData = workPart.Annotations.CreateComponentData(viewLabelObj)
For Each tC As Annotations.TextComponent In cData.GetTextComponents For Each aLine As String In tC.GetText lw.WriteLine(aT.GetEvaluatedText(viewLabelObj, aLine))
ViewName = aT.GetEvaluatedText(viewLabelObj, aLine)
Next
Next
lw.WriteLine("")
validViewParms = ufs.Draw.AskViewLabelParms(viewLabelTag, myLabel)
End If
If validViewParms = UFConstants.UF_DRAW_invalid_parameter Then
MsgBox("parameters could not be loaded for " & tempView.Name)
Continue For
End If
Next
Return ViewName
End Function

thanks
E