In Nx 11 PMI in Part Navigator i need to extract all the `Model Views' name except standard views in desending order.
Currently manually i am doing this by
(1) Clicking on `Name' in `Part Navigator' for descending order i.e., black filled arrow should be down,
(2) From top to bottom manually by selecting the view individually and pressing `F2' Rename copying to notepad except standard views and except symbol "" (Example : "MAIN_VIEW" should be copied to MAIN_VIEW without "").
Is there any option for this requirement ?
(a) All the 8 following standard views anmes should not be taken "Trimetric", "Top", "Right", "Left", "Isometric", "Front", "Bottom", "Back".
(b) Camera views no need to consider for copy.
thanks in advance
Solved! Go to Solution.
From Google i foudn a journal (attached in notepad) from above link.
This journal is shown the view names one by one by information box.
But i need all the view names except standard model view names in notepad sorted desending.
thanks in advance
Hi @Sekars ,
Below code gives the list of manually created views but I couldn't sort in descending order. Maybe you can just copy them in excel and sort them.
Option Strict Off Imports System Imports NXOpen Module NXJournal Sub Main Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow Dim displayPart As Part = theSession.Parts.Display 'Dim list As New List(Of String) Dim ViewNames() As String Dim views As ModelingViewCollection views = workPart.ModelingViews lw.open() For Each vw as ModelingView in views 'For Each vw as ModelingView in views.OrderByDescending(Function(v) v.Name) 'For Each vw as ModelingView in views.Cast(Of ModelingView)().OrderByDescending(Function(v) v.Name) ' lw.writeline(temp.Name.ToString) Select Case vw.Name.ToString Case "Back" Case "Bottom" Case "Front" Case "Isometric" Case "Left" Case "Right" Case "Top" Case "Trimetric" Case Else lw.writeline(vw.Name) ''' Print user added views End Select Next lw.close() End Sub End Module
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Module Module2 Sub Main() Dim theSession As Session = Session.GetSession() Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim userModelViews As New List(Of ModelingView) Dim cannedViews As Array cannedViews = System.Enum.GetNames(GetType(NXOpen.View.Canned)) 'iterate through the view collection, adding each view name to the string array For Each tempModelView As ModelingView In theSession.Parts.Work.ModelingViews Dim skip As Boolean = False For Each cannedView As String In cannedViews If tempModelView.Name = cannedView Then skip = True End If Next If Not skip Then userModelViews.Add(tempModelView) End If Next 'sort the list alphabetically userModelViews.Sort(AddressOf CompareViewNames) 'reverse the list userModelViews.Reverse() For Each temp As ModelingView In userModelViews lw.WriteLine(temp.Name) Next End Sub Private Function CompareViewNames(ByVal x As ModelingView, ByVal y As ModelingView) As Integer 'case-insensitive sort Dim myStringComp As StringComparer = StringComparer.CurrentCultureIgnoreCase 'for a case-sensitive sort (A-Z then a-z), change the above option to: 'Dim myStringComp As StringComparer = StringComparer.CurrentCulture Return myStringComp.Compare(x.Name, y.Name) End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End Module
Hello cowski1 and Samadhan
Thanks for your journals
Both cowski1 and Samadhan Journals working well, i will cowski1 since have the sort to descending option also.
Thanks once again for both of you