I have a recorded journal .vb from the customer site, that use NX10. The script as shown below:
Need guidance on how to modify it, so it will be able to be used as a command to create that attribute for other NX CAM sessions.
'=======================================================
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit PROGRAM")
Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")
Dim nCGroup1 As NXOpen.CAM.NCGroup = CType(workPart.CAMSetup.CAMGroupCollection.FindObject("PROGRAM"), NXOpen.CAM.NCGroup)
Dim programOrderGroupBuilder1 As NXOpen.CAM.ProgramOrderGroupBuilder
programOrderGroupBuilder1 = workPart.CAMSetup.CAMGroupCollection.CreateProgramOrderGroupBuilder(nCGroup1)
theSession.SetUndoMarkName(markId2, "Program Dialog")
Dim taggedObject1 As NXOpen.TaggedObject
taggedObject1 = programOrderGroupBuilder1.StartUdeSet.UdeList.FindItem(0)
Dim taggedObject2 As NXOpen.TaggedObject
taggedObject2 = programOrderGroupBuilder1.StartUdeSet.UdeList.FindItem(1)
Dim taggedObject3 As NXOpen.TaggedObject
taggedObject3 = programOrderGroupBuilder1.StartUdeSet.UdeList.FindItem(2)
' ----------------------------------------------
' Dialog Begin Program
' ----------------------------------------------
programOrderGroupBuilder1.Destroy()
theSession.UndoToMark(markId2, Nothing)
theSession.DeleteUndoMark(markId2, Nothing)
theSession.DeleteUndoMark(markId2, Nothing)
theSession.UndoToMark(markId1, "Edit PROGRAM")
theSession.DeleteUndoMarksUpToMark(markId1, "Edit PROGRAM", False)
' ----------------------------------------------
' Menu: Tools->Operation Navigator->Object->Properties
' ----------------------------------------------
Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
Dim objects1(0) As NXOpen.NXObject
objects1(0) = nCGroup1
Dim attributePropertiesBuilder1 As NXOpen.AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, NXOpen.AttributePropertiesBuilder.OperationType.None)
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = NXOpen.AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Units = "MilliMeter"
Dim objects2(0) As NXOpen.NXObject
objects2(0) = nCGroup1
Dim generalPropertiesBuilder1 As NXOpen.CAM.GeneralPropertiesBuilder
generalPropertiesBuilder1 = workPart.PropertiesManager.CreateGeneralCAMPropertiesBuilder(objects2)
generalPropertiesBuilder1.Name = "PROGRAM"
Dim objects3(0) As NXOpen.NXObject
objects3(0) = nCGroup1
attributePropertiesBuilder1.SetAttributeObjects(objects3)
attributePropertiesBuilder1.Units = "MilliMeter"
theSession.SetUndoMarkName(markId3, "CAM Task Properties Dialog")
attributePropertiesBuilder1.Title = "CNCOPERATOR"
Dim markId4 As NXOpen.Session.UndoMarkId
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "CAM Task Properties")
attributePropertiesBuilder1.StringValue = "OPERATOR-1"
theSession.DeleteUndoMark(markId4, Nothing)
Dim markId5 As NXOpen.Session.UndoMarkId
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "CAM Task Properties")
Dim nXObject1 As NXOpen.NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim nXObject2 As NXOpen.NXObject
nXObject2 = generalPropertiesBuilder1.Commit()
Dim id1 As NXOpen.Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(NXOpen.Session.MarkVisibility.Visible)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
theSession.DeleteUndoMark(markId5, Nothing)
theSession.SetUndoMarkName(id1, "CAM Task Properties")
attributePropertiesBuilder1.Destroy()
generalPropertiesBuilder1.Destroy()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
'========================================================