I am trying to Load the latest revision of a list of teamcentre Parts into NX. How would I go about getting a list of a given parts revisions for me to then chose the latest one from? Preferrably from teamcentre without having to load the part first?
I am currently trying to call
PartRevisions = UFSession.Ugmgr.ListPartRevisions(PartTag)
Which should return a tuple with the number of and names of the revisions of the part with the tag PartTag if I am not mistaken?
The issue I am now having is how do I obtain the part tag for a part on the database with a database id, for example"@DB/PartName/AA" ?
PartTag = UFSession.Part.AskPartTag("@DB/PartName/AA")
only returns "0" for a part that exists and has multiple revisions on the teamcenter server.
as always, any help would be much appreciated
edit: included MWE.. well.. not working
import NXOpen import NXOpen.PDM import NXOpen.UF def NXPrint(item): TheSession = NXOpen.Session.GetSession() TheSession.ListingWindow.Open() TheSession.ListingWindow.WriteLine(str("Debug Code:%s" % item)) UFSession = NXOpen.UF.UFSession.GetUFSession() PartTag = UFSession.Part.AskPartTag("@DB/PartName/AA") NXPrint(PartTag) PartRevisions = UFSession.Ugmgr.ListPartRevisions(PartTag)
Solved! Go to Solution.
A quick search on the forum found this:
The code is in VB, but it should give you an idea of the flow and functions required. There are probably other examples on the forum (or in the GTAC solution center); I didn't dig too deep.
First of all thank you for your reply.
I looked into the example you linked me and managed to solve the problem!
the code I came up with from the example is:
CurrentUFSession = NXOpen.UF.UFSession.GetUFSession()
PartTag = CurrentUFSession.Ugmgr.AskPartTag(PartName)
PartRevisions = CurrentUFSession.Ugmgr.ListPartRevisions(PartTag)
RevisionID = CurrentUFSession.Ugmgr.AskPartRevisionId(PartRevisions[(len(PartRevisions) - 1)])
PartAAString = "@DB/" + PartName+ '/' + RevisionID
Which returns the PartAAString as a string which can be used to pull the part with the newest revision on the database for a given PartName by the AddComponent() function or similar!
Thanks for your help @cowski1!