|
( k- A. T9 m5 ]" i/ F' N) uOption Strict Off2 \: f9 P1 z a/ d# z! r
Imports System
# {0 a2 d1 h# J3 O; zImports System.IO n! k; {1 F, d1 |2 L
Imports System.Windows.Forms; _% {/ g) T, t/ J3 _/ x
Imports NXOpen
& ^4 Z4 ^% d; |% oImports NXOpen.UF
1 ^! H) R9 v' |0 m. P' ?Imports NXOpen.Utilities) K, `' a1 R0 P9 f
% `: T* S* b8 u* H9 z! kModule TestRenameCamObjects0 P5 q- ?, O( K7 t% i5 ~; |
Dim theSession As Session = Session.GetSession()
3 U# X/ P8 w7 e# o# L" O K" A/ H9 a Dim theUFSession As UFSession = UFSession.GetUFSession()
- {: ?/ o, m0 m8 c5 k# |. l Dim theUI As UI = UI.GetUI() p( `; y8 j& j% S, X1 i
Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")/ t1 [0 ^: c7 S6 I- t& N8 T L
Dim ugRelease As String = Nothing8 |' o8 n% [$ F9 N# {. `9 y% ?
Dim UGFullRelease As String = Nothing
( w4 O' J( f- U
1 H7 f* H: U4 ]3 Z) m5 h Sub Main(Args As String())
% l5 X- u) i1 u! ^( Z! y theSession.LogFile.WriteLine("Executing ... " & _1 n8 q8 y- k! d$ X f) i. f: |
System.Reflection.Assembly.GetExecutingAssembly().Location)
6 `( o; z8 u+ ] w4 f/ ~
2 |/ u2 J( V0 D Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")& O' v! Y0 \( ]+ ~
Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")3 k) t; z9 {6 B/ p# K% d
. N. S. x' Y/ X) l7 K# e% [4 A
UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")& P! Q& Z! ~4 b6 E! s
UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")
; e; C s* d) e; z* \, ]
, S& z. ? V0 g+ v System.Windows.Forms.Application.EnableVisualStyles()" |7 ]& t, S, O% D. C
, R* h0 G% j8 l' s; ` A Dim MyUndoMark As Session.UndoMarkId = _( O. E8 J' a6 T; B) y) J, H
theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects"), y8 d) J5 C) ~9 |
6 W4 t/ t8 E B6 O9 i. `5 |" c) {$ T" l
' uncomment the following lines to check for the correct application
6 B6 t _6 ]( h% y Dim AppID As Integer = UFConstants.UF_APP_NONE: [7 E. N) e. d* U e7 L
theUFSession.UF.AskApplicationModule(AppID)
- Y/ d9 s3 \. M If AppID <> UFConstants.UF_APP_CAM Then
/ a5 j! M1 t# w) F: z& x. W theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")
" b# N5 y( Q* o0 h/ G7 A$ Y Exit Sub0 ?' m) b: w1 G+ b" z$ B' k
End If% k% M1 C- b {0 H/ H$ k6 I& _2 E
7 g f+ b& m7 ~- ]$ E7 a, U
For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1; R/ s+ p* T6 h$ L" \+ i2 p' L
Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)8 \' s2 L! B% u. H$ u0 g- Y
: C# o6 X0 x( D% \) I8 w
If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then! R$ h; ]6 ?, W9 n
Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)
- Q; {4 |" o6 ~& d/ s7 x
# \3 \7 M& \ X7 J Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")
; Q/ k! U9 P1 e2 m: x& @* Z , d& }' x( n: J' \" M) \
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)
' n X$ c$ P& N6 t & @6 _: `* z* c; L/ {
Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)
' n$ O3 k. u1 S8 {, h # [8 U3 V$ y& H/ i& S) K! g
theNcGroup.SetName(theGroupName)6 w* Z E/ y z0 Y
: m$ f5 A* N; Y3 G! { Dim theCounter As Integer = 0/ @2 M4 n+ s4 Z X; w
. ?4 v, P1 n+ E* {
For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()- T3 S' M: ?! Q2 _# P* J {
If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then
* a& _% m' x* D& Z theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)
1 x0 d2 G) D7 L% x ( l u9 ~& M9 z+ C# Q& Z0 B% L
theCounter += 1! F3 w9 M1 R- c" {, [( l: C: q
. k: G# r; `: v4 T0 |. N. c( d# f If theCounter > 99 Then Exit For0 K; G. o5 g: L) F6 ^
End If
% f+ S1 W/ X: |& J& i: {5 ? Next, a3 C( m; \. A4 d* |; {! p
End If# C/ X5 u7 |$ H, \/ ]8 z# x3 g: ^
Next' T6 b! C, z2 r: H$ z
End Sub
) O/ P x# ~# @4 i
) l( v6 N" { t( v Public Function GetUnloadOption(ByVal dummy As String) As Integer
; ]6 S; c2 X J Return CInt(Session.LibraryUnloadOption.Immediately)
8 k2 T( Z& Q9 {# f End Function
; w" j$ ]# y8 ?End Module |
|