Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Find (latest) Revisions of a NX Teamcenter Part [NXOpen][Python]

Experimenter
Experimenter

Hi Everyone,

 

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 Smiley Happy 

 

Kind Regards,

 

Lofes

 

edit: included MWE.. well.. not working Smiley Tongue 

 

 

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)

 

 

 

 

2 REPLIES 2

Re: Find (latest) Revisions of a NX Teamcenter Part [NXOpen][Python]

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

A quick search on the forum found this:

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/How-to-load-assem...

 

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.

Re: Find (latest) Revisions of a NX Teamcenter Part [NXOpen][Python]

Experimenter
Experimenter

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[1][(len(PartRevisions[1]) - 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! Smiley Happy