|
/ y# x9 [0 `9 a9 hOption Strict Off& ^5 Y6 G( _! z9 |
Imports System
2 ?2 h3 c% v7 G1 u2 V7 j, aImports System.IO
2 i# D+ s1 W% lImports System.Windows.Forms
! W! s" I. T& DImports NXOpen4 G+ i4 J# H7 r" D! r& M
Imports NXOpen.UF; W$ Q A5 g1 Q; u( i
Imports NXOpen.Utilities2 [, D7 h2 H5 K6 A8 E! B0 k6 e( n
$ ]- a; x& O* U/ D2 ^5 N. b
Module TestRenameCamObjects
" e0 L# }- Z6 _! N' ` Dim theSession As Session = Session.GetSession()0 s8 A |$ G% I: ~
Dim theUFSession As UFSession = UFSession.GetUFSession()2 s J$ |" x* v
Dim theUI As UI = UI.GetUI()0 W6 d8 v m. w( X5 a' |' h
Dim TempPath As String = Environment.GetEnvironmentVariable("TMP")
1 ]) D9 {5 x# W: E Dim ugRelease As String = Nothing
! k- f! Z% h* a! s: W: Z; D Dim UGFullRelease As String = Nothing9 r3 o! G; ?9 E2 y6 x9 ~5 J
' P5 f- a! ^- B! ~
Sub Main(Args As String())
1 i# v$ h+ x, e! o' S, k0 _ theSession.LogFile.WriteLine("Executing ... " & _
6 C0 e% l/ Z4 _6 B System.Reflection.Assembly.GetExecutingAssembly().Location)" |8 P0 I; [% K
/ N9 N- u, ~) ?, R$ B: {) m; p7 i Threading.Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo("en-US")
0 L; ?# A. {( z: _) I$ q1 g) x Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo("en-US")
5 \4 k0 e+ ^1 ^: l
: Z- a8 C* ^7 i% y; }- a UGRelease = theSession.GetEnvironmentVariableValue("UGII_VERSION")* }" N& v2 ?* D' \) \; x6 S
UGFullRelease = theSession.GetEnvironmentVariableValue("UGII_FULL_VERSION")6 S- Y2 x- m0 p7 M R
. b9 X5 F# m ~. T. P System.Windows.Forms.Application.EnableVisualStyles()( H \, r; \5 T# N% n9 T9 I0 }+ X8 v
' ~2 }6 e8 q7 e8 r3 X# t
Dim MyUndoMark As Session.UndoMarkId = _0 _3 h/ ~6 {% j6 A+ n3 @* i( z) v
theSession.SetUndoMark(Session.MarkVisibility.Visible, "TestRenameCamObjects")
5 D8 }' _; q6 W: c) v6 Z& B
2 w- R' K, T% Q' u6 x* Q1 b ' uncomment the following lines to check for the correct application
/ O5 x0 z9 b9 W0 |3 @( ^: w. ` Dim AppID As Integer = UFConstants.UF_APP_NONE4 k( U5 j+ |9 w! s( R
theUFSession.UF.AskApplicationModule(AppID)
) M+ W- W/ _% g+ y3 E, ^; T3 F If AppID <> UFConstants.UF_APP_CAM Then% \2 t! ]; b( T
theUI.NXMessageBox.Show("Application missmatch", NXMessageBox.DialogType.Error, "No NX CAM session, Exiting!")" r$ ~) L0 X2 `, W9 q
Exit Sub, C @' G% \* ]1 m8 [( @3 j
End If
n( _+ f& B( p& t: Y
, C% j8 ? N1 D! H4 W. ^ For i As Integer = 0 To theUI.SelectionManager.GetNumSelectedObjects() - 1
7 @# g6 K9 `+ P Dim theSelectedObject As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
s! e- e7 o5 _+ T5 n$ Y. x& Y
# M* j6 Y3 F5 @3 S2 J If theSession.Parts.Work.CAMSetup.IsGroup(theSelectedObject) Then
6 D0 x+ G8 B3 R: G" h" G& N, F- _ Dim thePartName As String = IO.Path.GetFileNameWithoutExtension(theSession.Parts.Work.FullPath)
" n9 K( p5 R: t8 ?
0 f( {1 }9 V8 L) W+ r: J( G Dim theIndex As String = NXOpenUI.NXInputBox.GetInputString("Enter Index")
8 K2 P$ o& q! q% M # Q! J7 [* I( v+ x7 y" _: G1 @
Dim theGroupName As String = Left(thePartName, 12).Replace("-", "_") & "_" & theIndex & "_" & Right(thePartName, 4)
/ T* v9 `* [9 ]5 y; _8 X5 U+ A! {) y
& C* U7 C( e/ c3 y+ B/ `/ I Dim theNcGroup As CAM.NCGroup = CType(theSelectedObject, CAM.NCGroup)! _% |( S. m7 W! E- x
% H* ]6 O% Z9 D' ` L$ z: S$ {! x
theNcGroup.SetName(theGroupName)
8 ~0 W) y5 ]7 `" K; E& L1 X 5 d- C, \( w& f5 v J$ n, j3 K! G
Dim theCounter As Integer = 0& d/ K9 ^1 ~; h5 e% _/ Z$ ~9 [+ b
$ U' d& t' o4 W
For Each theCAMObject As CAM.CAMObject In theNcGroup.GetMembers()
& e% l4 l, E4 W; n& X y If theSession.Parts.Work.CAMSetup.IsOperation(theCAMObject) Then; b! n' Z1 x4 L$ ~5 ^! h
theCAMObject.SetName(theCounter.ToString("00") & "_" & theCAMObject.Name)' X0 _# G$ A* m+ H
. t' J1 S* E$ K theCounter += 1) T+ o& S/ [. |& ]" W: H7 ?
2 F/ X* S% S0 f If theCounter > 99 Then Exit For
/ Z" D3 D M; x1 h! X9 ~ End If0 P, H2 R+ b! E& r
Next
9 b- C, ?) o+ B7 { End If6 }4 J+ c7 `& G$ a& T
Next
8 A0 Z/ R( R2 d" \! n8 |4 \0 [# ]7 { End Sub
* R/ U; g& ?: X
1 G6 V3 a# h7 j/ y+ v6 `0 i Public Function GetUnloadOption(ByVal dummy As String) As Integer
. r2 g& U8 J1 O) j. I5 u5 Y7 p Return CInt(Session.LibraryUnloadOption.Immediately)
; C9 L5 @' ]+ y: r5 h2 O End Function
% k; X: D, G3 @2 i4 R5 j4 Y1 Y& y/ S# PEnd Module |
|