×
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

journal to remove hashed expressions

journal to remove hashed expressions

journal to remove hashed expressions

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
























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