Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

journal to remove hashed expressions

Status
Not open for further replies.

Ehaviv

Computer
Joined
Jul 2, 2003
Messages
1,012
Location
IL
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
























 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top