|
3 @# M9 d+ G' n* x4 U$ p, j
Option Strict Off
0 V7 \2 K) ]! N3 q' B0 M3 MImports System
( `' A* t( {( V% zImports System.IO4 L3 J! U( z9 F! k' L: q
Imports System.Windows.Forms, n/ \# [5 G A$ j
Imports NXOpen
8 x q( o( {, G( P8 e6 P/ E1 r+ [Imports NXOpen.UF
8 d: F. {7 d8 I4 L- j2 mImports NXOpen.Utilities
& |) z; z3 G ?8 F+ l5 s, f4 T! o; L& [% X
Module TestRenameCamObjects+ g: t F4 ^ ]; p
Dim theSession As Session = Session.GetSession()
' W. }# N' n0 z w; n Dim theUFSession As UFSession = UFSession.GetUFSession()
: r' E7 n- a* v1 I Dim theUI As UI = UI.GetUI()) f' u. c/ H5 ^) c, o
Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")4 V% K& a- W+ T) R: I, e( n! M
Dim ugRelease As String = Nothing
- f1 t2 G( [& c& [. _; }, C% E+ H5 u Dim UGFullRelease As String = Nothing
$ N5 s' m9 \. L" \
3 o, u( w d8 \) ] Sub Main(Args As String())
; l5 o( Q8 L* A" `. H6 w$ Q theSession.LogFile.WriteLine("Executing ... " & _0 r! m7 U9 P0 g4 N; C
System.Reflection.Assembly.GetExecutingAssembly().Location)
5 H1 m; w3 z2 R. G. G& |9 ~
# s2 j- T- x( r, f% g+ ]* l* _: _0 n) z Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")8 }5 t7 y; U T' p7 O, @. H
Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")
$ h! c) k6 R( t3 L8 Z ! P- o1 u/ C0 t, r. v
UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")
# I5 k" c0 M! K, i4 t2 q% I2 g UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")
' ^7 i! F; j& Q# N" W m 9 u# L# j& |7 O( ^! v
System.Windows.Forms.Application.EnableVisualStyles()
) J# k6 Z; e- s, m6 E0 T
1 {# k% K8 N; `9 M; b Dim MyUndoMark As Session.UndoMarkId = _
5 X3 Z2 K4 d4 x& p$ P4 w, X theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects")# T) h$ Y& L5 t! Z3 s, A
, Y T9 w9 i# ^: `( u3 V
' uncomment the following lines to check for the correct application
% Z. q& G6 N. u8 g' M6 z( A Dim AppID As Integer = UFConstants.UF_APP_NONE
y/ w* ~; w; _7 A. A, Q7 |7 O5 ~ theUFSession.UF.AskApplicationModule(AppID)
5 ?2 J5 Q) e- R& W If AppID <> UFConstants.UF_APP_CAM Then
4 B# x5 j7 @1 W7 x- k theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")/ Y4 S( @5 ~3 f5 h# z3 o
Exit Sub
0 d& C" B) I6 w6 J: I End If
8 p5 M* o) J1 ~0 W( b$ a' n 7 I- ~; u+ J9 i# [! h3 x" R( _/ f
For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1
" _( j6 M; n# I' Z Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i); B/ a8 B' T8 n- ?9 U
$ x+ Q9 U6 l4 X' o5 y, D
If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then7 P% j! F+ u+ I6 x8 }
Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)
/ d: h$ a9 g8 Y 1 v5 m9 b) C- W [5 L/ y/ q8 |
Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")
. f/ M: f3 i/ G8 L/ V1 y 1 y/ _+ I3 G2 N6 D, ?& P
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)9 ], }$ l0 q( H; A3 A! F2 ~
) }" r8 j) y4 U7 N/ V7 r
Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup), X3 l3 A4 |8 Z6 {
) n3 A- ?1 O2 V( A, q( r' I* o theNcGroup.SetName(theGroupName)" o$ K- a( r" t) f! ~
- G8 a7 k3 q- X3 o Q* l Dim theCounter As Integer = 0
7 b b! W4 h7 V$ r: [( n# P( Y! N K
7 j% {5 o y. Y2 w$ \$ f0 Z# t- ^ For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers(). C6 T1 g! i" Q. {
If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then& b' F; \( ^" ]8 W! V
theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name): w% Q# z" `! l* j9 g# V
6 o @/ }5 [- i% V theCounter += 1
1 @2 K/ g% y K9 \ , U2 _5 D4 M2 i8 v
If theCounter > 99 Then Exit For
( b3 K( m' e- w End If
7 ~: A& J8 R6 b6 a( M. B Next$ ?, \7 M/ p5 p! n: N. R# v
End If
3 p4 ?% [# T e Next
4 C7 u. a( }! f/ N7 z End Sub, ^ c# l- m) } B
. @& X. G4 t- D8 P* N9 | Public Function GetUnloadOption(ByVal dummy As String) As Integer
6 J. t4 o# j2 H: {: Y Return CInt(Session.LibraryUnloadOption.Immediately)
7 n) ~* Q% A" @" d0 R6 [ End Function, w; N3 H0 h/ {; l: [
End Module |
|