Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

jerry007

Aerospace
Jul 18, 2011
16
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!
 
Replies continue below

Recommended for you

no :-(
I am trying to put this biz logic in a "Note"
 
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)?
 
The string is from db_part_no. Yes, the result will be put in a drafting note.
 
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.
 
Thanks a lot! How do I set it to run on "file open"! Sorry, I am new to UG.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor