Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 783

How to get View Letter MsgBox("view letter: "& myLabel.view_letter)

$
0
0

Below is the code which is available in this site, I am interested in getting view latter, but when i am executing the below code i am getting below error

System.ArgumentNullException: value cannot be null
Parameter Name: s
at System.Text.UTF8Encoding.GetByteCount(string chars)
at NXOpen.UF.Util.ConertStructStringstoUTF8(object inStruct, Object outStruct, Dictionary` array_len_info)
at NXOpen.UF.UFDraw.AskViewLabelParms(tag view_label_tag, ViewLabelParms_ view_label_parms)

Can you please help me to get view label

code is here

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)

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

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 in Advance


Viewing all articles
Browse latest Browse all 783

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>