×
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

How do I save/display the return from the splitString()?

How do I save/display the return from the splitString()?

How do I save/display the return from the splitString()?

(OP)
How do I get rid of the first word from a string?  For instance, I'd like to display "is a test" from a given string "This is a test".  Thanks!

RE: How do I save/display the return from the splitString()?

Does this question relate to a journal? If so, the Split function returns an array of 'words' based on the delimiter you specified.

http://msdn.microsoft.com/en-us/library/6x627e5f(v=vs.80).aspx

If this isn't part of a journal, ignore the above link! smile

RE: How do I save/display the return from the splitString()?

(OP)
no sad
I am trying to put this biz logic in a "Note"  

RE: How do I save/display the return from the splitString()?

Where is the source string coming from (drafting note, attribute, external spreadsheet, database, etc)? Where do you want to put the result (appears to be a drafting note based on your post)?

RE: How do I save/display the return from the splitString()?

(OP)
The string is from db_part_no.  Yes, the result will be put in a drafting note.

RE: How do I save/display the return from the splitString()?

I have not found a straightforward way to do this, but here is a small journal that will take the DB_PART_NAME attribute, process it and assign it to a new attribute. You can then reference this new attribute in your note. You could set up a custom button or menu item to be run at will or set it up to run at a 'user exit' point (file open, file save, etc) so it runs automatically. The journal operates on the work part. Save the following as a text file and change the extension from .txt to .vb.

CODE

Option Strict Off
Imports System
Imports System.IO
Imports NXOpen

Module NXJournal

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

'***********************************************************************

Sub Main

Dim strPartName as string

  Try
    strPartName = workPart.GetStringAttribute("DB_PART_NAME")
    strPartName = Trim(strPartName)
  Catch ex As Exception
    strPartName = ""
  End Try

  'msgbox(strPartName)
  if InStr(strPartName, " ") > 0 then
    strPartName = Mid(strPartName, InStr(strPartName, " ") + 1)
  end if
  'msgbox("$" & strPartName & "$")
  'the next line will create a new attribute with the processed text, change the name as necessary
  workPart.SetAttribute("CUSTOM_PART_NAME", strPartName)

End Sub
'***********************************************************************


End Module

I can already think of some improvements for this, but I'll throw it out as is to see if this approach will even work for your situation.

RE: How do I save/display the return from the splitString()?

(OP)
Thanks a lot!  How do I set it to run on "file open"!  Sorry, I am new to UG.

RE: How do I save/display the return from the splitString()?

It's been a while since I have set up menu files, user exits, and such. Your best bet would be to search the help files with a term such as "run journal from menu item", see what you can get from there and post questions as needed.

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