|
2 P: Y, \/ n( e6 b) U8 r
Option Strict Off1 ~! K0 j" w! Y+ l |+ O. p) X% x
Imports System* j* D+ X9 C/ A% X/ \' x9 B; a3 g
Imports System.IO
+ z: ^' z" L, S9 H" kImports System.Windows.Forms
2 _% N+ t+ [3 i, YImports NXOpen2 t( j2 k, X1 O& x& X: T
Imports NXOpen.UF
* X- v$ I& q0 o1 U+ _3 w% t$ fImports NXOpen.Utilities6 }+ B7 h4 f2 r& N! ?
2 n. o7 {5 X0 w& {3 j/ ~* f
Module TestRenameCamObjects, a; f5 Y% g+ a6 }9 g
Dim theSession As Session = Session.GetSession()
. O1 O$ o# f7 }1 \" f Dim theUFSession As UFSession = UFSession.GetUFSession()
: g# N4 s/ V1 f Dim theUI As UI = UI.GetUI()
" k& m/ p& s9 t2 G' S$ S Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")- V. T! a# O4 p! {$ K& j
Dim ugRelease As String = Nothing
( ?) H' Y* J( X0 h, | Dim UGFullRelease As String = Nothing: f( E; A5 D3 _
/ k7 J4 K' T; Q$ m" B$ ]) w: s2 J4 h
Sub Main(Args As String())
' [! A2 e# `/ t/ y! D3 c4 n0 W( j8 ~ theSession.LogFile.WriteLine("Executing ... " & _
, T. \ |3 C# e, x System.Reflection.Assembly.GetExecutingAssembly().Location)
! N* o( a6 K* F2 I
5 {7 Z' y; \ z- [, U. P6 C4 q# G Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
; X. Z% y. I+ K Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")! r8 j( d K7 l, t
, h* J& R$ u! m; Z2 B7 Y0 I UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")9 I0 U+ Y |& |7 _
UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")
& L' O+ i1 c. E2 P6 J- D
/ v' m9 R# W' a. z* v/ y System.Windows.Forms.Application.EnableVisualStyles()
7 A* b- {- Y( W0 E* M2 p* a3 ?
3 K8 r1 j" P5 e E$ B Dim MyUndoMark As Session.UndoMarkId = _
9 ]5 ^* F& V+ X) I theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects")6 Z1 p( a M# E4 @
) N5 v# q$ Q+ n/ v) p% g6 j r
' uncomment the following lines to check for the correct application
) L4 U+ q$ o+ _ Dim AppID As Integer = UFConstants.UF_APP_NONE% R8 v$ T$ l1 _4 B8 d3 ?. _* H
theUFSession.UF.AskApplicationModule(AppID); R! T& e6 V# F
If AppID <> UFConstants.UF_APP_CAM Then2 h% H1 m/ v* @+ m- [) L1 \' @$ [
theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
; C0 v: e6 j' P0 j- c5 q7 E8 R Exit Sub, A! c, J. D. M/ h
End If7 A# A. L" F6 y) |6 E1 }5 |. B
) A6 y* C$ a2 N0 [: O* a, A
For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1
1 A" `. Q7 T* B3 c% S Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
' I1 Y$ I' g7 I( Z" B! d # F: g& K% g! r
If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then
" O6 q& S4 [* H4 ^0 \- a& B Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)- D6 A6 G: @& S6 R( o k" o; l9 M
( H4 M7 F+ a3 F. Z) g Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")
% k* u/ v2 G0 a0 w2 K% |7 Q# A 6 h9 z/ @' h4 ~9 t6 B; g% \! d( t
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)5 R. o! l7 Q0 ^. {* T8 Q; f
' b5 p+ S! o* _* y3 ` Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)
3 C# Q+ t0 T# n, I' w
# e6 q5 W5 @# Z; O5 b0 n1 ~: o theNcGroup.SetName(theGroupName)
" y/ |6 p9 O' v' b' _
" t8 Q2 X4 E& V; M% e. E: ^) y Dim theCounter As Integer = 0
" N) i1 c8 v' K8 @3 h4 T) _! `7 d& ~" _
7 H* q6 z4 N9 z8 a R' D) J For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()
6 [2 A# O: S, [. _; v8 ` If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then
( a! j2 p9 Y8 @+ l( W8 z3 s theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)
$ T0 ?( o+ x5 R* ^
1 F& [0 s; Q3 w/ w( A4 g0 z4 F5 ^ theCounter += 1
7 n7 w! B5 x8 O& ~6 A/ x2 v
6 ~- ~- X0 T7 z8 w/ B0 U If theCounter > 99 Then Exit For! B. |3 J& I6 `1 `/ c$ e
End If
: F9 N: u0 G- R9 n8 u) M Next
9 n+ o- |/ u5 ]4 I' h End If
# |/ ^3 m9 f* K# R( ?+ \( H5 z; G# j Next0 x: O$ t# K- p+ k; \. }
End Sub: |* A1 _0 l! L- i1 f
% G4 C& ^3 a }3 p+ v Public Function GetUnloadOption(ByVal dummy As String) As Integer: D+ J/ j# E* \: G$ b
Return CInt(Session.LibraryUnloadOption.Immediately)6 u7 z% f! U) [$ x/ v- {: |3 k
End Function8 X: d+ u; r6 s, p8 {4 A' B n h
End Module |
|