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..
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