Submitted by rakesh_paka on Thu, 02/18/2021 - 21:09
Forums:
Hi,
I am Trying to print he x and y coordinates for view labels. Could any one guide me with any reference or which kind of property need to be used.
Thank you.
Regards.
Hi,
I am Trying to print he x and y coordinates for view labels. Could any one guide me with any reference or which kind of property need to be used.
Thank you.
Regards.
re: view label coordinates
Below is some code that reports the drafting view labels (text, coordinates, etc).
'NXJournaling.com
'February 19, 2021
'report view label (text, letter, coordinates, etc)
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module4
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
lw.Open()
Const undoMarkName As String = "view label coordinates"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
For Each temp As Drawings.DraftingView In theSession.Parts.Work.DraftingViews
lw.WriteLine(temp.Name)
'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
lw.WriteLine("label not shown")
lw.WriteLine("")
Continue For
End If
Dim viewLabelTag As Tag
theUfSession.Draw.AskViewLabel(temp.Tag, viewLabelTag)
Dim viewLabelObj As Annotations.Note = Utilities.NXObjectManager.Get(viewLabelTag)
lw.WriteLine("view label coordinates: " & viewLabelObj.AnnotationOrigin.ToString)
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("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
Dim viewlabels1(0) As NXOpen.DisplayableObject
viewlabels1(0) = viewLabelObj
Dim editViewLabelSettingsBuilder1 As NXOpen.Drawings.EditViewLabelSettingsBuilder
editViewLabelSettingsBuilder1 = theSession.Parts.Work.SettingsManager.CreateDrawingEditViewLabelSettingsBuilder(viewlabels1)
Dim editsettingsbuilders1(0) As NXOpen.Drafting.BaseEditSettingsBuilder
editsettingsbuilders1(0) = editViewLabelSettingsBuilder1
theSession.Parts.Work.SettingsManager.ProcessForMultipleObjectsSettings(editsettingsbuilders1)
lw.WriteLine("view letter: " & editViewLabelSettingsBuilder1.ViewCommonViewLabel.Letter)
lw.WriteLine("")
lw.WriteLine("")
editViewLabelSettingsBuilder1.Destroy()
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 a lot.....
Thanks a lot.....