×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Remove hashed expressions - with On Error GoTo Handler Method

Remove hashed expressions - with On Error GoTo Handler Method

Remove hashed expressions - with On Error GoTo Handler Method

(OP)
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

RE: Remove hashed expressions - with On Error GoTo Handler Method

I liked the version with Try Catch better...

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources