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..
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 ?
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 ?
RE: A better way to open latest revision of a part, using NxOpen/Journal ?
RE: A better way to open latest revision of a part, using NxOpen/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 ?
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 ?
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 IfMark Benson
Aerodynamic Model Designer
To a Designer, the glass was right on CAD.