|
admin
发表于 2019-4-17 07:54:25
C#的 没有用NX 函数 5 {7 a7 _# ~+ n1 ^- Q. N
Z' Y. ^+ f* ~7 q/ a) q4 }# R& h. t$ D4 Z% T
[mw_shl_code=csharp,true] Public Class list_all_parts_in_directory5 a* i# C7 d2 n
+ \" \1 D" h" f: K1 G( D
Public Shared Sub Main()# G9 _! v5 u3 J& G
* P P1 |1 w3 r* Q, |
Dim theSession As Session = Session.GetSession()
! @, v& p4 y) q4 D/ c Dim lw As ListingWindow = theSession.ListingWindow()! i! N( I' e. L" q8 u$ W0 s1 U
/ [+ D: w& D) p/ z, I; b+ ^* F) @
Dim foldername As String = ""
1 B; d" Q1 y( [/ C lw.Open()
# L# P/ C7 M& |# b3 e If (select_directory(foldername) <> DialogResult.OK) Then4 ?* i! {; }; M8 }# A
lw.WriteLine("Input canceled...exit" & vbCrLf)2 {+ p! k: h; a# ]! |, P
Return' n5 C- s- ^) r- d0 \! h
End If
& r/ n1 m2 O6 |: P, b$ O, a
8 T* }2 T4 X U' q Dim dir As DirectoryInfo = New DirectoryInfo(foldername)
/ b3 R; L2 R' W5 _$ ` Dim fsi As FileSystemInfo9 K+ _- |7 U. S) `6 q8 t$ @/ Q
4 R! d7 E$ F0 S2 u lw.Open(); V, P7 P, S) p2 @8 I( b' H
lw.WriteLine("Parts in directory: " _1 `0 i4 \" v. i: I( D
& Path.GetFullPath(dir.ToString()) & vbCrLf)1 q x3 @3 ~7 R& c! n% v
8 ? M4 `) s; s, p: C* V% L% Z For Each fsi In dir.GetFileSystemInfos()
( z+ u4 s8 M, E; ~3 k If (TypeOf fsi Is FileInfo And fsi.Extension.Contains("prt")) Then
+ }6 o$ S6 e, I% O) n6 c8 o Dim f As FileInfo = CType(fsi, FileInfo)
6 j! R' W% M! ^0 ]9 V Dim size As Long = f.Length
' G7 D2 O+ L: P9 S5 X9 J$ K7 `* e; o/ { lw.WriteLine(f.Name & " " & size & "Bytes" & vbCrLf)( T- {- U, ?6 Z" r7 c
End If
: o& L3 f* Y( Y7 J Next fsi6 N* O `' | E8 n! b' X; `, a! J
! x" W% I; I0 D" _( q- ?2 x
End Sub; v. v" @1 \+ \, c% F8 ~' l
, T! `7 i; u/ J Public Shared Function select_directory(ByRef foldername) As System.Windows.Forms.DialogResult
! Z( }9 \$ ~5 x) J
, `, f( z3 g$ r, U. {3 H5 I Dim fbd As FolderBrowserDialog3 _: k3 Y) I1 ~6 v: T7 `
Dim result As System.Windows.Forms.DialogResult# H% b2 ^) u# e, {
7 @# V x; n& k2 O" o0 ?# {
fbd = New System.Windows.Forms.FolderBrowserDialog()
* h( O% ~, Y# D, K9 {$ I. ^1 R fbd.Description = "Select directory to check"7 N! R( L, M8 z# }9 i# i. r7 ]7 s
fbd.ShowNewFolderButton = False( ^) t5 u$ v8 G. Q; l: A
' start browsing at Desktop folder, uncomment for any other default directory
2 W [! Z% P: L ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR")
w- c" Q7 o+ B' ^+ j1 G/ N! ] ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR") + "\Moldwizard"! m# u5 H. V: J' z9 Z$ p1 q# n
' fbd.SelectedPath = "c:\aaa\bbb"3 s$ K! o, ^6 \4 Z' @& h7 V
result = fbd.ShowDialog()" G0 ], N- I: K3 q7 z3 _3 u; Q
foldername = fbd.SelectedPath1 h' a/ M! `+ l& | ?- f
fbd.Dispose()
8 g5 J& U5 r0 q b, B7 f$ ?1 d Return result I, }. T4 J) ]9 K. k
! }6 a C/ B& A r9 z3 U! r6 C End Function
* `! M, A! D. I3 P# v0 X9 H/ G1 s
Public Function GetUnloadOption(ByVal dummy As String) As Integer* s z5 G0 G2 R: J. i
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
) B% U, H( @, g! \& U End Function9 s% Z* h1 T' f$ s; T) l
, j+ B, s# r* X( C& Z. C End Class[/mw_shl_code]
" P/ R+ E) }# P7 r( s( W |
|