|
( f6 B# j9 [$ t+ m
Option Strict Off
0 }6 P8 _; ^& t7 P* TImports System( ]% ^6 ~1 y& a. i# Q
Imports System.IO5 Y, E& p1 a! |" ?5 S; r
Imports System.Windows.Forms& F3 p( L+ P1 X9 c
Imports NXOpen
" Y9 E$ D- F( \2 }# g) uImports NXOpen.UF
% d& [( H0 x8 x1 _" dImports NXOpen.Utilities
* b' ?4 u5 V. u$ A6 V: m4 n
) W* o, ?# Y N7 L- Q% m' V# ~& X# Z0 mModule TestRenameCamObjects, `" I' ^& T4 |+ ~
Dim theSession As Session = Session.GetSession()
6 Z* a1 c: I) `) r* N Dim theUFSession As UFSession = UFSession.GetUFSession()2 c, O1 z4 c) C/ O+ V# ^, y8 T! p. |
Dim theUI As UI = UI.GetUI()
7 G1 ~7 ]7 |) h- T7 |( T. N! U Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")( X7 e* x% ^. T p t0 ?4 u- Y6 y" | [
Dim ugRelease As String = Nothing, J7 a i4 l$ v0 ~& s7 b0 r% F
Dim UGFullRelease As String = Nothing
2 |+ O) ^, }% n2 [, S! m% U2 N
- W+ z$ j% m6 q3 y8 \8 N, f Sub Main(Args As String()); }/ N( ~3 g2 }. g$ n, a
theSession.LogFile.WriteLine("Executing ... " & _
1 w$ K" E0 `6 m" R System.Reflection.Assembly.GetExecutingAssembly().Location)
" |) `* o" W9 {7 L7 U . U% `( ^7 W/ D7 Y
Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")1 J8 y; n9 z9 {' v
Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")
: K: D5 q4 l0 V$ D, a 9 K6 k. Y7 B5 d% Z
UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")/ ~+ i7 l0 y8 c6 ~/ R# J
UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")% Y `* k- Q! D3 M7 x
7 o* H, S* ?" R+ G7 B- T
System.Windows.Forms.Application.EnableVisualStyles()
8 ?# V/ @( N0 s8 U; J, z . s- v/ A& T; v% j; X
Dim MyUndoMark As Session.UndoMarkId = _
' l/ w1 v) H4 L( C) r; t theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects")
/ k- K5 ?. ]+ i , ^3 l( I& t! X4 L Y7 z) g, A
' uncomment the following lines to check for the correct application
3 l0 {/ X( G* r# S Dim AppID As Integer = UFConstants.UF_APP_NONE
& Z4 F' @, `8 N2 e; S theUFSession.UF.AskApplicationModule(AppID)
, ^5 G) [. Y/ Q9 l+ ` If AppID <> UFConstants.UF_APP_CAM Then- H* C& @/ V" w8 |6 W* ~$ b
theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
y7 ~: i2 k: s2 T Exit Sub& V. y9 \& Q+ v1 ^
End If
9 f8 T: x' s' u% {& A
f2 W1 p- I6 | For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1
! \6 J: F+ P2 Y4 P Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)8 |) l8 Z6 k q* g' [
0 T ^2 U# o) y6 h If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then/ z# e! O5 l! Z% J& J6 r0 [
Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)% ]8 k% o" O0 s" I. {* F
. z; F' g( N1 X" i/ k. n2 [ Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")4 n7 n( Y- s6 v% ]
! R2 \4 ~6 @, u4 O1 m8 t
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)
2 S! c# K' n5 h, D) C
& x- q7 V$ q; U6 G. L9 B8 Z Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)
, c1 c& n6 }7 l6 Y, @ & B* E2 z; R' Z% K/ f! g
theNcGroup.SetName(theGroupName)
) j9 E- p7 S1 I0 m; F2 k & {; M f9 ]8 q) Z2 ?; o: I+ m
Dim theCounter As Integer = 08 F6 T7 M. \7 Z# W) f
0 [8 t* ?! z0 k# P" n For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()
1 I" D1 k7 K$ A3 }5 j# W4 b If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then3 X3 |5 s5 A. N
theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)- |7 R3 ?; j ]2 I" G
; b& p' H8 i8 }; I! f3 r
theCounter += 1
8 t2 N6 ~7 X2 `+ w4 t
$ N- j; l, F2 I. J If theCounter > 99 Then Exit For
! `! ~2 v2 j5 B End If
# a+ [' C* k! v }. B. l Next
- q$ p; J* O2 M/ M5 o End If
# T* `- [+ `/ I Next
: Q4 p. S/ X0 m% o1 K( { End Sub
5 B: h7 K# h2 n1 s+ `1 s" z! p
: k- h' R Q4 f+ f" U; ^2 H Public Function GetUnloadOption(ByVal dummy As String) As Integer
& W1 y3 G" Z9 ~) l4 m Return CInt(Session.LibraryUnloadOption.Immediately)
1 P \" K8 H1 c End Function
8 _- u/ x- ^9 ^: p M# Q) } W: ?End Module |
|