cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with NX Journal to add component in Teamcenter

Experimenter
Experimenter

I'm using NX8.5 and have been exploring journal recently, also I don't have any programming background and so I hope you'll be able to help me with my question. I manually added a part in my assembly and recorded the journal. However, when I try to run for the second time to add the same component again, an error was prompt to me (picture attached). Below are the codes of my journal. 

==================================================================================

 

' NX 8.5.3.3
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Assemblies->Components->Add Component...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Add Component")

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

theSession.SetUndoMarkName(markId2, "Add Component Dialog")

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

theSession.SetUndoMarkName(markId3, "Part file name Dialog")

' ----------------------------------------------
' Dialog Begin Part file name
' ----------------------------------------------
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Part file name")

theSession.DeleteUndoMark(markId4, Nothing)

Dim markId5 As Session.UndoMarkId
markId5 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Part file name")

theSession.DeleteUndoMark(markId5, Nothing)

theSession.SetUndoMarkName(markId3, "Part file name")

theSession.DeleteUndoMark(markId3, Nothing)

theSession.Parts.SetNonmasterSeedPartData("@DB/11A05001702-7005/A")

Dim basePart1 As BasePart
Dim partLoadStatus1 As PartLoadStatus
basePart1 = theSession.Parts.OpenBase("@DB/11A05001702-7005/A", partLoadStatus1)

partLoadStatus1.Dispose()
Dim markId6 As Session.UndoMarkId
markId6 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Add Component")

theSession.DeleteUndoMark(markId6, Nothing)

Dim markId7 As Session.UndoMarkId
markId7 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Add Component")

Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim orientation1 As Matrix3x3
orientation1.Xx = 1.0
orientation1.Xy = 0.0
orientation1.Xz = 0.0
orientation1.Yx = 0.0
orientation1.Yy = 1.0
orientation1.Yz = 0.0
orientation1.Zx = 0.0
orientation1.Zy = 0.0
orientation1.Zz = 1.0
Dim partLoadStatus2 As PartLoadStatus
Dim component1 As Assemblies.Component
component1 = workPart.ComponentAssembly.AddComponent("%UGMGR=V3.2 PH=R3WhCM8AW$3T8B PRH=R3ehCM8AW$3T8B PN=11A05001702-7005 PRN=A RT=""has shape"" AT=""UG master part file"" ", "MODEL", "11A05001702-7005", basePoint1, orientation1, -1, partLoadStatus2, True)

partLoadStatus2.Dispose()
theSession.DeleteUndoMark(markId7, Nothing)

theSession.SetUndoMarkName(markId2, "Add Component")

theSession.DeleteUndoMark(markId2, Nothing)

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

 

Please note that I'm using a TC/NX integrated system. Thank you very much!

1 REPLY

Re: Problem with NX Journal to add component in Teamcenter

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi,

The journal is repeating exaclty the steps you have recorded and is trying to open the same part one more time and this is resulting in the error message. 

Sooner or later you will need some scripting to make the journal more flexible.

xtof