NX Please provide workaround for "File Size List" not available in NX (see S.E.)

2021-10-06T23:26:17Z
NX for Design

Summary


Details

Please provide workaround for "File Size List" not available in NX, 
similar to the SolidEdge solution.


User needs to see the File Size in Kbyte for each Assembly Component 
residing on Hard Disk. 



Solution

PLEASE REMEMBER THAT THIS PROGRAM IS OFFERED AS FREE OF CHARGE SOLUTION, 
BUT IT IS NOT INTENDED TO BE SUPPORTED BY GTAC. 
IF YOU NEED ASSISTANCE WITH IT PLEASE CONTACT AN NX EXPERT, OR ASK FOR 
A CONSULTANCY OFFER, BY CONTACTING YOUR SIEMENS SALES MANAGER. Thank you. 
------------------------------------------------------------------------- 
INSTRUCTIONS : 
Please delete all these lines up to the stars. 
Then implement this very simple Visual Basic Program, by saving it 
inside a file on Disk called : RUN_Size_sorted+rounded.vb (or whatever)


For running it 
1) e.g. on NX12.0.1 go to "Tools" Ribbon and click on "Play Journal". 
2) Browse... 
3) select the file RUN_Size_sorted+rounded.vb 
4) OK 
5) hit "Run" 
6) an Information Window will open up and will show each filename, and 
 its size in rounded Kilobytes, ordered from smaller to bigger.


************************************************************************ 
'----------------------------------------------------------------------- 
' Author : PRESALES PRODUCT ENGINEERING - France 
' Company : Siemens PLM Software 
'----------------------------------------------------------------------- 
Option Strict Off 
Imports Microsoft.VisualBasic 
Imports System 
Imports System.IO 
Imports NXOpen 
Imports NXOpen.UF


Module TMP 
 Dim s As Session = Session.GetSession() 
 Dim ufs As UFSession = UFSession.GetUFSession() 
 Dim lw As ListingWindow = s.ListingWindow 
 Dim NXMessageBox As NXMessageBox = NXOpen.UI.GetUI().NXMessageBox


 Sub Main()


 Dim basePart As BasePart = s.Parts.BaseWork 
 If basePart Is Nothing Then 
 NXMessageBox.Show("", NXMessageBox.DialogType.Error, "No Work 
Part") 
 Return 
 End If


 Dim sizeInBytes As Long = 0 
 Dim nbPart As Integer = 0


 ' Count the number of part in the session 
 For Each part As Part In s.Parts 
 nbPart = nbPart + 1 
 Next


 ' Get all the partname in an array 
 Dim partname(nbPart - 1) As String 
 Dim i As Byte = 0 
 For Each part As Part In s.Parts 
 partname(i) = part.FullPath 
 i = i + 1 
 Next


 Array.Sort(partname) ' Sort the array alphabetically


 ' Write the result to the NX listing Windows 
 lw.Open() 
 For i = 0 To nbPart - 1 
 Dim partFile As New FileInfo(partname(i)) 
 sizeInBytes = partFile.Length 
 Dim j As Byte = partname(i).LastIndexOf("\") + 1 
 lw.WriteLine(partname(i).Substring(j) & " File size = " & 
Format(sizeInBytes / 1024, "########") & " Kb") 
 Next


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



Notes and References





Hardware/Software Configuration

Platform: all
OS: n/a
OS Version: n/a
Product: NX
Application: GATEWAY
Version: V11.0.2
Function: ATTRIBUTES

Ref: 001-8368437

KB Article ID# PL8003880

Contents

SummaryDetails

Associated Components

Modeling