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!

Remove hashed expressions - with On Error GoTo Handler Method 1

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 remove_hashed_expressions
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
old_name = myExp.Name
new_name = myExp.Name.Substring(0,myExp.Name.IndexOf("'"c))

On Error GoTo Handler

workPart.Expressions.Rename(myExp,new_name)

If err Then
lw.WriteLine(old_name & " - UnChanged - " & _
"*** " & n1.ToString & " ***")
err = False
Else

lw.WriteLine(old_name & " - Changed to - " & new_name)

End If

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 hashed expression names exist")
end if

lw.Close

Handler:
'Error means expression name conflict
' n1 count them
n1 = n1 + 1
err = True
Resume Next

End Sub

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top