×
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

A better way to open latest revision of a part, using NxOpen/Journal ?

A better way to open latest revision of a part, using NxOpen/Journal ?

A better way to open latest revision of a part, using NxOpen/Journal ?

(OP)
I sometimes need to open a list of parts and do something with them.
Is there a better way than the one shown below to open (from TeamCenter) the latest revision of a part?
Now I just try with rev = Z first and keep on trying, not so elegant..

CODE --> (VB)

' NX 8.5.0.23
' Journal created by RTM to open the latest revision of a part from TCE
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String) 
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession .ListingWindow
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
'   Menu: File->Open...
' ----------------------------------------------

dim sPartNumber as string = "114713"  'This is one of many parts I want to open, just an example 
dim sFileName as string 
dim i as integer

for i = 90 to 65 step -1 '(Revisions Z = asc90 to A = asc65)
  sFilename =  "@DB/" & spartNumber & "/" & Chr(i)
  on error resume next
  theSession.Parts.SetNonmasterSeedPartData(sFileName)
  Dim basePart1 As BasePart
  Dim partLoadStatus1 As PartLoadStatus
  basePart1 = theSession.Parts.OpenBaseDisplay(sFileName, partLoadStatus1)

  if err.number<>0 then 
	err.clear 'Try again
  else 
	lw.Open
	lw.Writeline (vbcr & "---" & vbcr & "Opened file : " & sFileName & vbcr & "  ( i.e. Rev = " & Chr (i) &" ) " & vbcr &  "---")
	exit sub
  end if
next i

End Sub
End Module 

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

1. List all the revisions:
ufs.Ugmgr.ListPartRevisions(db_part_tag, revision_count, revisions)
2. Get the last one in the array:
ufs.Ugmgr.AskPartRevisionId(revisions(UBound(revisions)), revision_id)

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

(OP)
Thanks :)

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

The load options in Teamcenter has many options that can be set to what you desire.

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

(OP)
Yes, but does settings in TCE make any difference in a Journal?
If I open manually I always get the latest revision, but in a Journal I have to specify, it seems.

/RT

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

Hi - The one and only way to do it , (as I see it) , is to list all revisions , and afterwards ask for last rev in array.

ufs.Ugmgr.ListPartRevisions(db_part_tag, revision_count, revisions)
ufs.Ugmgr.AskPartRevisionId(revisions(UBound(revisions)), revision_id)

---
I use these UFUgmgr Class functions in a program that I have created to list all drawing specifications, belonging to the current workpart.
Simply listet in a listbox if more than one drawing , and user just need to pick the desired drawing ,and it will open in NX.
If only one specification excist, it open immediately without displaying a listbox.

lklo

RE: A better way to open latest revision of a part, using NxOpen/Journal ?

You can also use the following, this gives the latest revision based on your set revision rules in NX.

CODE -->

Dim rev_tag As Tag
        Dim part_tag As Tag
        Dim rev_string As String = ""
        theUFSession.Ugmgr.AskPartTag(part_name, part_tag)
        ' MsgBox(part_tag)
        If part_tag <> NXOpen.Tag.Null Then


            theUFSession.Ugmgr.AskConfiguredRev(part_tag, rev_tag)
            theUFSession.Ugmgr.AskPartRevisionId(rev_tag, rev_string)

        Else
            rev_string = "00"
        End If 

Mark Benson
Aerodynamic Model Designer

To a Designer, the glass was right on CAD.

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