Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Export attributes of items contained in a folder structure in Teamcenter

nt-_-ts

Marine/Ocean
Dec 31, 2024
1
Hello,

I need some help exporting details of Teamcenter items that are spread throughout a folder structure.

An example of the structure:

Root Folder with standards
----Standards folder 01
--------Teamcenter item 01
--------Teamcenter item 02
----Standards folder 02
--------Teamcenter item 03
--------Additional folder 01
-------------Teamcenter item 04

So the items and folders inside the root folder are inconsistent.

Without admin rights, is there a way I can export the attributes of the items contained inside the Root Folder? I would need the revision, release date, date modified etc. In an item structure I can use the Tools > Export > Objects to Excel functionality of the Structure Manager. The solution can be with either Teamcenter or NX functionality.
 
Replies continue below

Recommended for you

I'm not sure i understand the question.
If you have an assembly , load that into the Structure manager or NX, set up the required columns and then do the export.
The revision/ revision dates / status etc is depending on the revision rule / precise or imprecise / has nothing to do with the folder ?
The Folder will show the items, with all existing revisions, both released and not.

Regards,
Tomas
 
Hello,

I need some help exporting details of Teamcenter items that are spread throughout a folder structure.

An example of the structure:

Root Folder with standards
----Standards folder 01
--------Teamcenter item 01
--------Teamcenter item 02
----Standards folder 02
--------Teamcenter item 03
--------Additional folder 01
-------------Teamcenter item 04

So the items and folders inside the root folder are inconsistent.

Without admin rights, is there a way I can export the attributes of the items contained inside the Root Folder? I would need the revision, release date, date modified etc. In an item structure I can use the Tools > Export > Objects to Excel functionality of the Structure Manager. The solution can be with either Teamcenter or NX functionality.
This Journal exports all of the attributes from components into txt files from an assembly in Native NX. All of the txt files land in the folder of the top level asm file.
I did not write it and I'm not sure where I found it, its not signed.


Code:
Option Strict Off

Imports System
Imports System.IO
Imports NXOpen
Imports NXOpen.Assemblies
Imports NXOpen.UF

Module report_component_attributes
' Set allComponents below to True to report attributes for all the components
' and subcomponenets in the displayed part.
Dim allComponents As Boolean = True
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = theSession.ListingWindow
Dim dispPart As Part = theSession.Parts.Display()
Dim wrtPath As String = Path.GetDirectoryName(dispPart.FullPath)

Sub Main
    Dim modified As Boolean
    modified = ufs.Part.IsModified(theSession.Parts.Display.Tag)
    lw.SelectDevice(ListingWindow.DeviceType.Window, "")
    ' Open the listing Window to display information to user
    lw.Open()
    Dim fullFileName As String = System.IO.Path.Combine( _
                Path.GetDirectoryName(dispPart.FullPath), _
                Path.GetFileNameWithoutExtension( _
                dispPart.FullPath))
    lw.WriteLine(fullFileName & _
        " modified = " & modified.ToString)
    reportAttributes(wrtPath, dispPart)
    Dim root As Component = _
        theSession.Parts.Display.ComponentAssembly.RootComponent
    reportComponentChildren(root, 1)
End Sub
    
Sub reportComponentChildren(ByVal comp As Component, _
    ByVal indent As Integer)
    Dim child As Component = Nothing
    Dim space As String = Nothing
    Dim c_part As Part = Nothing
    Dim loaded As Integer
    Dim modified As Boolean
    
    For ii As Integer = 1 To indent
        space = space & " "
    Next
    For Each child In comp.GetChildren()
        loaded = ufs.Part.IsLoaded(child.DisplayName())
        If loaded = 0 Then
            lw.WriteLine(space & child.DisplayName() & " (unloaded)")
        Else
        c_part = child.Prototype()
        modified = ufs.Part.IsModified(c_part.Tag)
'        lw.WriteLine(space & (CType(c_part, Part)).FullPath & _
'                " modified = " & modified.ToString)
        Dim fullFileName As String = System.IO.Path.Combine( _
                    Path.GetDirectoryName(c_part.FullPath), _
                    Path.GetFileNameWithoutExtension( _
                    c_part.FullPath))
        lw.WriteLine(space & fullFileName & _
            " modified = " & modified.ToString)
        reportAttributes(wrtPath, c_part)
    End If
    if allComponents Then
        reportComponentChildren(child, indent + 1)
    End If
   Next
End Sub

Sub reportAttributes(ByRef wrtPath As String, ByVal dispPart As Part)
    Dim attr_info() As NXObject.AttributeInformation
    attr_info = dispPart.GetAttributeTitlesByType(NXObject.AttributeType.String)
    Dim title As String = ""
    Dim inx As Integer = 0
    Dim count As Integer = attr_info.Length()
    Dim attrVal As String
    If count <= 0 Then
        lw.WriteLine("No Attributes ...")
'        No Attributes
    Else
    Dim fName As String = System.IO.Path.Combine(wrtPath, String.Concat(Path.GetFileNameWithoutExtension(dispPart.FullPath), ".txt"))
    Dim f As File
    Dim filewrite As IO.StreamWriter
    'create file and write to it....
    filewrite = f.CreateText(fName)
    lw.WriteLine("Part attributes written to ... " & fName)
    filewrite.WriteLine("Part attributes for " & dispPart.FullPath)
    Do Until inx = count
        Dim result As Integer = 0
        title = attr_info(inx).Title.ToString
        attrVal = dispPart.GetStringAttribute(title)
'        lw.WriteLine(title & " = " & attrVal)
        filewrite.WriteLine(title & " = " & attrVal)
        inx += 1
    Loop
    filewrite.Close()
End If
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
    Return Session.LibraryUnloadOption.Immediately
End Function

End Module
 

Part and Inventory Search

Sponsor