Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

RagnarThor

Mechanical
Oct 31, 2014
4
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:
' 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
 
Replies continue below

Recommended for you

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)
 
The load options in Teamcenter has many options that can be set to what you desire.
 
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
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor