×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Turn Part Family Member in normal Part by Journal

Turn Part Family Member in normal Part by Journal

Turn Part Family Member in normal Part by Journal

(OP)
Hello,

we often get Assemblies from suppliers that need to be imported into Teamcenter. These Assemblies contain parts from Part Families. I know that it is possible to convert Part Family members into normal Parts during the import process. But I have to add additional attributes to all parts of the assembly before I start the Import (e.g. OS_Part_Name). Is there a way to switch a Part Family part into a normal part by using a journal because Part Family members can not be saved with their changes.

This is my journal to add the needed attribute to all parts in one directory. But I need help to remove the Part Family information.

CODE --> vb

Option Strict Off
Imports System
Imports NXOpen
Imports System.Diagnostics
 
 
 
Module NXJournal
Sub Main
 
' Overall StopWatch
Dim stopWatch as StopWatch = new StopWatch()
Dim value As TimeSpan
Dim totalTime As String
 
' Individual Part StopWatch
Dim partWatch as StopWatch = new StopWatch()
Dim partTime As TimeSpan
Dim totalPartTime As String
 
 
' User Entry
Dim path As String
path = "C:\Temp\test_refile\"
 
Dim logFileName As String
logFileName = "C:\Temp\test_refile\xxxx.txt"
 
 
 
stopWatch.Start()
 
Dim theSession As Session = Session.GetSession()
 
Dim loadedPart As String
 
Dim loadParts() As String
 
' Read Directory
Dim directory As New IO.DirectoryInfo(path)
Dim directoryFiles As IO.FileInfo() = directory.GetFiles()
Dim fileNames As IO.FileInfo
 
 
Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim markId1 As Session.UndoMarkId
Dim partSaveStatus1 As PartSaveStatus
Dim OS_FileName As String = Nothing
Dim write_at As String = "OS_File_Name"

 
For Each fileNames In directoryFiles
 
 
  Dim read_at As String = ""
  
  ' Start the StopWatch
  partWatch.Start()
 
  ' ----------------------------------------------
  '   Menu: File->Open...
  ' ----------------------------------------------
 
  basePart1 = theSession.Parts.OpenBaseDisplay(path + fileNames.Name, partLoadStatus1)
 
  partLoadStatus1.Dispose()
  
  markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Enter Gateway")
  
  workPart = theSession.Parts.Work
  
  workPart.ModelingViews.WorkView.Fit()
  ' ----------------------------------------------
  '   Write OS_FileName Attribute 
  ' ----------------------------------------------
		Try
			OS_FileName = fileNames.Name.Remove(fileNames.Name.Length - 4, 4)
            workPart.SetAttribute(write_at, OS_FileName)
        Catch ex As Exception
            MsgBox(write_at & " : " & OS_FileName & ex.Message)
        End Try 
 
 
  ' ----------------------------------------------
  '   Menu: File->Save
  ' ----------------------------------------------

 
  partSaveStatus1 = workPart.Save(BasePart.SaveComponents.False, BasePart.CloseAfterSave.False)
 
  partSaveStatus1.Dispose()
  
  ' ----------------------------------------------
  '   Read OS_FileName Attribute 
  ' ----------------------------------------------
		Try
            read_at = workPart.GetStringAttribute(write_at)
        Catch ex As Exception
            MsgBox(write_at & " : " & OS_FileName & ex.Message)
        End Try 
  
  ' ----------------------------------------------
  '   Menu: File->Close->All Parts
  ' ----------------------------------------------
  theSession.Parts.CloseAll(BasePart.CloseModified.CloseModified, Nothing)
 
  workPart = Nothing
  displayPart = Nothing
  partSaveStatus1 = Nothing
  basePart1 = Nothing
 
  partWatch.Stop()
 
  partTime = partWatch.Elapsed
  totalPartTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", partTime.Hours, partTime.Minutes, partTime.Seconds, partTime.Milliseconds/10)
 
  My.Computer.FileSystem.WriteAllText (logFileName, "Loaded: " + path + fileNames.Name + Environment.NewLine, True)
  My.Computer.FileSystem.WriteAllText (logFileName, "OS_FileName: " + read_at  + Environment.NewLine, True)
  My.Computer.FileSystem.WriteAllText (logFileName, "Elapse Time: " + totalPartTime + Environment.NewLine + Environment.NewLine, True)
 
Next
 
 
' ----------------------------------------------
'   Menu: Tools->Journal->Stop
' ----------------------------------------------
 
stopWatch.Stop()
 
value = stopWatch.Elapsed
totalTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", value.Hours, value.Minutes, value.Seconds, value.Milliseconds/10)
 
My.Computer.FileSystem.WriteAllText (logFileName, Environment.NewLine , true)
My.Computer.FileSystem.WriteAllText (logFileName, "Total Load Time: " + totalTime, true)
 
 
End Sub
End Module 


Thanks in advance
Carsten

RE: Turn Part Family Member in normal Part by Journal

If you perform a Save-As on the family member, the newly created part will not be associated to the family table.

www.nxjournaling.com

RE: Turn Part Family Member in normal Part by Journal

(OP)
That works perfect. It can be so easy. bigsmile

Thank you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources