|
|
admin
发表于 2019-4-17 07:54:25
C#的 没有用NX 函数 + g2 i x+ _1 H0 L
% D) f5 }* y+ \/ {9 w# S% a
% Q5 O* ` i @+ E[mw_shl_code=csharp,true] Public Class list_all_parts_in_directory
8 g, f1 @, B) O; b; J: ]- E. J/ L! F" n0 v5 ]& J
Public Shared Sub Main()
' G1 I3 p. p3 g( u
! v/ A* P! P4 a+ V, s i Dim theSession As Session = Session.GetSession()# Z9 R9 P) e H) L" V* i
Dim lw As ListingWindow = theSession.ListingWindow()7 s9 t3 g' H5 N0 ]" ]0 C( K
% \! j( U4 w( C' Y
Dim foldername As String = ""
+ x( p! ^2 u+ }! {) q lw.Open()
# z8 G; [; z" M% F/ v7 ] If (select_directory(foldername) <> DialogResult.OK) Then/ r) i* \. J; @) l$ H5 u
lw.WriteLine("Input canceled...exit" & vbCrLf)
+ {! u- t7 h1 e8 V0 H ~ k Return
0 g+ S! k6 V' J% ~4 m) h End If& Q8 E+ ~8 U; g
: R* h! s2 Y- Y8 x' V' q
Dim dir As DirectoryInfo = New DirectoryInfo(foldername)
9 y) Q5 r8 L5 u9 W7 w n Dim fsi As FileSystemInfo7 ~9 P% M9 i9 M, p# q9 c1 ^
- S6 T X' ~3 w$ E$ G+ p
lw.Open()
0 K* l. R: `: `8 m% M lw.WriteLine("Parts in directory: " _
/ q+ m ]3 T% e: c# O & Path.GetFullPath(dir.ToString()) & vbCrLf)2 R; E" S1 [% T- ~& H6 w- \2 _( \
5 B4 N; s& }* C( f% d+ y
For Each fsi In dir.GetFileSystemInfos()
: s" O7 e0 C: w( Z1 x( w+ ^ If (TypeOf fsi Is FileInfo And fsi.Extension.Contains("prt")) Then5 g# P) b j% {$ R
Dim f As FileInfo = CType(fsi, FileInfo)
I4 x, {4 [$ `7 u+ U Dim size As Long = f.Length! M, u" v( I$ u' E3 m; Q
lw.WriteLine(f.Name & " " & size & "Bytes" & vbCrLf)( v0 e& r3 @4 X! p+ M1 B
End If% ~4 ~- [, Z) u# A5 R( D* c. S
Next fsi9 |6 j1 z9 l5 `. Y% i! J
" `& D: k, [' X+ L' u7 C
End Sub
; y9 Y4 ?% o1 o" T" p4 H
; _* U" i/ W1 J' T# B1 v1 o. H6 o4 U Public Shared Function select_directory(ByRef foldername) As System.Windows.Forms.DialogResult' |& m/ k0 m5 i+ c" Q% ?4 W. l8 `
( e, A, s5 @7 `( x4 {" \" }
Dim fbd As FolderBrowserDialog
9 j% X9 [! R1 }6 i! n o Dim result As System.Windows.Forms.DialogResult
& {3 @9 h1 L" Y3 P3 I0 z1 ]8 }8 Z! L' v
fbd = New System.Windows.Forms.FolderBrowserDialog()( ]' L+ D+ F' \1 Y) U V3 z. j
fbd.Description = "Select directory to check"
' y* Y6 s- y: y fbd.ShowNewFolderButton = False; A* ^% e* y3 {9 s3 s8 }, c, K
' start browsing at Desktop folder, uncomment for any other default directory
6 z6 n' ]4 L: p3 l, ~6 t- Z) L ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR")
8 w& J- s6 O! X4 q2 [ ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR") + "\Moldwizard". ^& Z+ B3 }# Y/ p6 Y* Q; }
' fbd.SelectedPath = "c:\aaa\bbb"
1 u* n, T% L p1 _- e+ Y* X* ^* z result = fbd.ShowDialog()
; W; J2 g' W) P* o* ?6 J foldername = fbd.SelectedPath
) P+ w S; ]7 G% ^) | r7 y9 u fbd.Dispose()( a E' o9 g+ E: P7 D
Return result
. l/ ~" U4 T+ F7 Z: _8 s: }( ^6 B; ~( g( S; v
End Function
a; L; V, T4 q0 z2 n9 |+ o5 Q, ]* z; M& I* y+ m& @7 Y
Public Function GetUnloadOption(ByVal dummy As String) As Integer9 Q8 R; ]( {% _2 S6 `
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
- ~( Z& S$ O: q1 ~* h I; @ End Function$ o, T6 g+ s2 M. A0 z
$ F8 g' w& ?% U3 K" m* f/ ^3 Z/ U% W
End Class[/mw_shl_code]
) E0 g; w# @' {: z) f/ `4 @; Q |
|