|
/ `8 ]+ y7 ?- X- ~# C, e% L: fOption Strict Off! r8 y$ S" X4 }) T! B
Imports System( `; {* k7 A. R2 f0 @; {
Imports System.IO
, N" }; n6 y4 }$ m8 P5 {Imports System.Windows.Forms" |: s. {( d6 m% l+ z: a4 I: |. j
Imports NXOpen* o5 G3 D+ C) b! [+ u
Imports NXOpen.UF1 B0 {+ ]- h7 Y$ ~' p# k5 Y
Imports NXOpen.Utilities0 Y/ z8 ], U9 i o
6 d$ F7 p( o* a* S5 k
Module TestRenameCamObjects# @2 `7 P8 N8 S: f) Y+ F( G
Dim theSession As Session = Session.GetSession()4 H5 K" S. M8 j Q( v& j
Dim theUFSession As UFSession = UFSession.GetUFSession()+ z. `/ x# p# D N. K5 q1 T
Dim theUI As UI = UI.GetUI()2 O# S8 F2 W8 e
Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")
6 Q2 }0 R$ Z( Z7 k4 q& j Dim ugRelease As String = Nothing
$ W- L& k3 f5 i! L7 V. E Dim UGFullRelease As String = Nothing
3 d3 Y8 U! C) n8 c
: ^( V+ K' G. \2 e: Y Sub Main(Args As String())6 G6 [1 E; p7 ]. x
theSession.LogFile.WriteLine("Executing ... " & _
0 A! s5 W% z+ I! [, _ System.Reflection.Assembly.GetExecutingAssembly().Location)
. B# e8 ^ A r! v1 M* g! N
, d A$ E/ T! Z1 C5 B a( }! _ Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
' f5 U- a( k1 B) R* G% A Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")
9 P5 B# o* o+ W: j
" S4 h$ Y; `' g& l$ U UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")
8 M+ z% ~; n$ C) N UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")' I, _2 x) N) a
& g* q* D1 i6 [' d
System.Windows.Forms.Application.EnableVisualStyles()8 g- g0 N9 S: n# \: ]: P! Q$ u/ A
8 g4 v" s2 @ z8 h1 t Dim MyUndoMark As Session.UndoMarkId = _7 a! [( p% |6 }) p! O
theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects"), Q7 _0 G8 H4 P5 F6 Q: ~$ X' N
" V7 q8 t8 r- Y( X4 n: W% U- l: E ' uncomment the following lines to check for the correct application
5 ^- d, C: V( i/ o8 x Dim AppID As Integer = UFConstants.UF_APP_NONE+ H1 F! M1 v+ }& A
theUFSession.UF.AskApplicationModule(AppID)8 Y; `; U1 |* D& O+ D# R6 V
If AppID <> UFConstants.UF_APP_CAM Then
2 }# Y- B$ Y! [& M4 u& ? theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
2 ]+ r7 B6 l9 t6 R3 { Exit Sub* {2 p5 S/ h- K# t
End If
$ s) E7 m9 B/ n" d
% ^# Q% ?- d0 ^- F1 f1 u4 `- a9 c$ ~ For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1. t P' Q6 C" V; J6 F
Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
2 _" a6 J) T1 q9 X- f
6 O; I4 g5 u D" G. y If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then( ?8 d0 N$ Z8 _) g' V2 N
Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)
+ p! x; W0 i. U$ ^7 X) j 1 n1 @+ l$ k* t. A6 `# ]
Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")
9 J) n& R6 E# P" v ! W" A. Z$ f `9 O4 z) }( \! u
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)
! [2 w; C( v. Z, n$ H& y9 O # Y0 |5 m& `3 }# O+ ?) P
Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)
W W' t- W( V/ K& H h2 H8 U7 a 2 b$ D( H/ P/ t/ V2 x( K, t; }
theNcGroup.SetName(theGroupName)- v4 r6 I1 i) S
8 J) J( s/ t* q C Dim theCounter As Integer = 02 |7 l0 t7 u5 \% R/ \0 n; c
; z- Y+ v# L, ]5 C6 P& s For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()
" k# R% o; c! q a If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then6 I/ ?1 D# B0 y: k: J# D: N+ T) W
theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)
: }3 G' W5 x/ i( i! Q
; \5 ~9 x+ n: Z: z* ?: | theCounter += 1
6 {& N! o( |. W: C
' W9 H6 v9 b5 W9 U0 Z If theCounter > 99 Then Exit For
, V% M, y. W% z8 N& i6 f9 o3 i End If S0 M7 @8 U' j4 `$ `' [$ j
Next' a' s& c; {8 x# b1 c
End If- L. S1 g3 \& y$ D* C- I* \
Next# U5 ?2 w/ h+ K4 ~1 t* `. F# I
End Sub
( R: m. v: g. p/ V; A 2 ~+ R0 a; `) ?' z) V
Public Function GetUnloadOption(ByVal dummy As String) As Integer1 `' s1 a3 @9 r+ J) ]" l7 _
Return CInt(Session.LibraryUnloadOption.Immediately)3 M$ V$ o, [ E t
End Function3 S4 n( y8 ?& Q8 _6 _. z. W
End Module |
|