|
admin
发表于 2019-4-17 07:54:25
C#的 没有用NX 函数 7 Y' m9 X, M* }) s) ]
! [6 b) {+ w! m5 d5 E& o& V
/ X& ~! i4 ? G) W/ i" ~( K[mw_shl_code=csharp,true] Public Class list_all_parts_in_directory0 D" i5 ]) k% i5 U& g
) |( H# M& W% U. U% t Public Shared Sub Main()
N" H3 Z# ]. [* Z2 }( q& ?4 z3 }1 a7 g) b; @$ |( ^
Dim theSession As Session = Session.GetSession()& \ g6 a& D' h6 H2 s
Dim lw As ListingWindow = theSession.ListingWindow()
* q( {" J4 ^: ^& L) X1 i) C' G t% e0 ^
Dim foldername As String = ""2 k# g- g; z$ c
lw.Open()4 o* v) k1 b7 F2 g- d% g
If (select_directory(foldername) <> DialogResult.OK) Then4 N, V' z7 X B
lw.WriteLine("Input canceled...exit" & vbCrLf)3 K, g1 i& u2 i
Return% q% \- u- b5 F( S
End If9 Q" j, q$ [3 x6 w$ I g- H' ~$ R
9 G0 y$ R: X" m2 X: H/ s/ D) w Dim dir As DirectoryInfo = New DirectoryInfo(foldername)
) ?! r" T* i! j+ s! m Dim fsi As FileSystemInfo& A' K' n+ W7 v5 v) B& F3 E
3 g+ T( c6 P7 c lw.Open()3 b3 r2 e- M9 V0 h" p
lw.WriteLine("Parts in directory: " _7 d5 o1 ^/ o7 C( [% x9 u, T4 R1 [
& Path.GetFullPath(dir.ToString()) & vbCrLf)2 X0 C6 |# F7 i8 Z6 A
3 e4 t! H8 q3 [# S' Z
For Each fsi In dir.GetFileSystemInfos()
* o L9 U& k6 O: G If (TypeOf fsi Is FileInfo And fsi.Extension.Contains("prt")) Then9 d$ t2 J# J$ m1 s+ ]7 O H/ w5 J, j
Dim f As FileInfo = CType(fsi, FileInfo)! n8 t% Y" x# t& a; Q
Dim size As Long = f.Length
( o) w3 i1 F z+ y# k+ [ lw.WriteLine(f.Name & " " & size & "Bytes" & vbCrLf)
7 M& b* t* T- V( ?0 ]' [; g End If1 z; q8 d: l0 N: g! b" R
Next fsi
0 ?; \' @; n, n/ F& ~5 j) B9 B
% k/ S! j0 k1 ^' r/ u% C End Sub. w, ?; T- d5 A6 b5 f! g+ ?. u
! |" J# B1 }; f0 a/ m+ c
Public Shared Function select_directory(ByRef foldername) As System.Windows.Forms.DialogResult
/ Z2 W1 p, f% r: ^7 @; T+ |+ Z1 U! p! q: i k; m' M
Dim fbd As FolderBrowserDialog' P; h6 i, N4 C$ H
Dim result As System.Windows.Forms.DialogResult+ [6 \' _" l" g4 B* S6 A2 U- D( D
% g) {+ l0 K( R9 S$ [
fbd = New System.Windows.Forms.FolderBrowserDialog()4 G7 T9 u8 q! i0 a+ {; r
fbd.Description = "Select directory to check"
' Y' J' n( {& I, c fbd.ShowNewFolderButton = False
8 R, W9 y4 [6 a$ m# Z ' start browsing at Desktop folder, uncomment for any other default directory- d. F9 N2 z7 @* O, w
' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR")
0 n9 V6 |6 r6 o5 k$ d) S ' fbd.SelectedPath = GetEnvironmentVariable("UGII_BASE_DIR") + "\Moldwizard"( s" J, u$ a z) X% b. k$ K
' fbd.SelectedPath = "c:\aaa\bbb"+ p- h% f; c0 q
result = fbd.ShowDialog()
; N- u5 K y/ t2 ~! U* G2 S9 { foldername = fbd.SelectedPath
& @4 C( d& `6 E" {4 c fbd.Dispose(); Q, ]; a: m4 h& Z
Return result
, W8 q3 q. C" m% [' A
' N" |8 s! q% z End Function3 s! k# E) q' H) J
( D3 t$ o4 e0 G- b# g! E$ ]& T1 @ Public Function GetUnloadOption(ByVal dummy As String) As Integer
" B; Y$ u' I5 t! G GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
( A. ~6 t- K" c* N- c0 t+ ]" D End Function
4 ?* W+ E) Z7 y0 k. r
& f7 Q9 w, q+ |1 Z' G* X+ z7 ^ End Class[/mw_shl_code]' f6 Q+ V; r) b- g$ x- E
|
|