Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim i as Integer = 0
Dim n1 As Integer = 0
Dim err As Boolean = False
Dim new_name As String
Dim old_name As String
Dim myExpressions as Expression()
myExpressions = workPart.Expressions.ToArray()
lw.Open
For Each myExp as Expression in myExpressions
if (myExp.Name.IndexOf("'"c)) > -1 then
i += 1
Try
old_name = myExp.Name
new_name = myExp.Name.Substring(0,myExp.Name.IndexOf("'"c))
workPart.Expressions.Rename(myExp,new_name)
lw.WriteLine(old_name & " - Changed to - " & new_name)
Catch e As Exception
'Error means expression name conflict
' n1 count them
n1 = n1 + 1
err = True
Finally
If err Then
lw.WriteLine(myExp.Name & " - UnChanged - " & _
"*** " & n1.ToString & " ***")
err = False
End If
End Try
lw.WriteLine(myExp.Name & " = " & myExp.RightHandSide)
lw.WriteLine("========================================")
end if
Next
lw.WriteLine("Number of unchanged expressions = " & n1.ToString)
if i = 0 then
lw.WriteLine("No expression names matched the specified regular expression")
end if
lw.Close
End Sub
End Module
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
Dim i as Integer = 0
Dim n1 As Integer = 0
Dim err As Boolean = False
Dim new_name As String
Dim old_name As String
Dim myExpressions as Expression()
myExpressions = workPart.Expressions.ToArray()
lw.Open
For Each myExp as Expression in myExpressions
if (myExp.Name.IndexOf("'"c)) > -1 then
i += 1
Try
old_name = myExp.Name
new_name = myExp.Name.Substring(0,myExp.Name.IndexOf("'"c))
workPart.Expressions.Rename(myExp,new_name)
lw.WriteLine(old_name & " - Changed to - " & new_name)
Catch e As Exception
'Error means expression name conflict
' n1 count them
n1 = n1 + 1
err = True
Finally
If err Then
lw.WriteLine(myExp.Name & " - UnChanged - " & _
"*** " & n1.ToString & " ***")
err = False
End If
End Try
lw.WriteLine(myExp.Name & " = " & myExp.RightHandSide)
lw.WriteLine("========================================")
end if
Next
lw.WriteLine("Number of unchanged expressions = " & n1.ToString)
if i = 0 then
lw.WriteLine("No expression names matched the specified regular expression")
end if
lw.Close
End Sub
End Module