Engraving on the components

Hi,
I don't have any knowledge to edit the Journals to make it work on other similar components
Could someone share me more helpful resources to edit my own journals as needed

Someone please edit the code for me to work on other part files as well
using this journal, I am trying to engrave on the face & the curve as reference of a component
the engraving is "J1234 BODY 1" & "HH P20"
The part file name is "J1234_Body1" & I set the material of the Part as "HH P20" in the attributes
I would like someone to edit this journal to engrave on the component with user selected Face & Curve by reading the values for "J1234 BODY1" from the Part file name and the Material "HH P20" from the material attributes of the part file

Here is the journal I recorded

Imports System
Imports NXOpen

Module SCJournal
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

' ----------------------------------------------
' Menu: Insert->Curve->Text...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim nullNXOpen_Features_Text As NXOpen.Features.Text = Nothing

Dim textBuilder1 As NXOpen.Features.TextBuilder = Nothing
textBuilder1 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text)

Dim origin1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal1 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane1 As NXOpen.Plane = Nothing
plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling)

textBuilder1.SectionPlane = plane1

Dim unit1 As NXOpen.Unit = Nothing
unit1 = textBuilder1.PlanarFrame.Length.Units

Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim coordinates1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim point1 As NXOpen.Point = Nothing
point1 = workPart.Points.CreatePoint(coordinates1)

textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder1.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western)

textBuilder1.TextString = "Text"

theSession.SetUndoMarkName(markId1, "Text Dialog")

textBuilder1.Type = NXOpen.Features.TextBuilder.Types.OnFace

Dim extrude1 As NXOpen.Features.Extrude = CType(workPart.Features.FindObject("EXTRUDE(1)"), NXOpen.Features.Extrude)

Dim face1 As NXOpen.Face = CType(extrude1.FindObject("FACE 160 {(0.2078271909714,-2.5,2.3754756627385) EXTRUDE(1)}"), NXOpen.Face)

Dim boundaryFaces1(-1) As NXOpen.Face
Dim faceTangentRule1 As NXOpen.FaceTangentRule = Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(face1, boundaryFaces1, 0.5)

Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = faceTangentRule1
textBuilder1.PlacementFaces.ReplaceRules(rules1, False)

textBuilder1.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)

Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "section mark")

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, Nothing)

Dim edge1 As NXOpen.Edge = CType(extrude1.FindObject("EDGE * 160 BLEND(4) 2 {(0,-4.2030442415266,0)(0.2078271909714,-3.9952170505553,2.3754756627385)(0.4156543819427,-3.7873898595839,4.7509513254771) EXTRUDE(1)}"), NXOpen.Edge)

Dim nullNXOpen_Edge As NXOpen.Edge = Nothing

Dim edgeTangentRule1 As NXOpen.EdgeTangentRule = Nothing
edgeTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeTangent(edge1, nullNXOpen_Edge, True, 0.5, False, False)

textBuilder1.OnFacePlacementProfile.AllowSelfIntersection(True)

Dim rules2(0) As NXOpen.SelectionIntentRule
rules2(0) = edgeTangentRule1
Dim nullNXOpen_NXObject As NXOpen.NXObject = Nothing

Dim helpPoint1 As NXOpen.Point3d = New NXOpen.Point3d(0.22045142856811575, -3.9825928129584871, 2.5197713587520219)
textBuilder1.OnFacePlacementProfile.AddToSection(rules2, edge1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False)

theSession.DeleteUndoMark(markId3, Nothing)

theSession.DeleteUndoMark(markId2, Nothing)

textBuilder1.Script = NXOpen.Features.TextBuilder.ScriptOptions.Baltic

textBuilder1.Script = NXOpen.Features.TextBuilder.ScriptOptions.CentralEuropean

textBuilder1.SelectFont("Arial Black", NXOpen.Features.TextBuilder.ScriptOptions.Western)

textBuilder1.SelectFont("Modern", NXOpen.Features.TextBuilder.ScriptOptions.Oem)

textBuilder1.OnFacePlacementProfile.ReverseDirection()

textBuilder1.FrameOnPath.Offset.RightHandSide = "1.4"

textBuilder1.FrameOnPath.Offset.RightHandSide = "1.5"

textBuilder1.FrameOnPath.Offset.RightHandSide = "1.6"

textBuilder1.FrameOnPath.Offset.RightHandSide = "1.7"

textBuilder1.FrameOnPath.Offset.RightHandSide = "1.5"

textBuilder1.TextString = "Tex"

textBuilder1.TextString = "Te"

textBuilder1.TextString = ""

textBuilder1.TextString = "J"

textBuilder1.TextString = "J1"

textBuilder1.TextString = "J12"

textBuilder1.TextString = "J123"

textBuilder1.TextString = "J1234"

textBuilder1.TextString = "J1234 BODY 1"

textBuilder1.FrameOnPath.Height.RightHandSide = ".25"

textBuilder1.FrameOnPath.WScale = 50.0

textBuilder1.FrameOnPath.WScale = 100.0

textBuilder1.FrameOnPath.Length.RightHandSide = "1"

textBuilder1.FrameOnPath.Length.RightHandSide = "2"

textBuilder1.PlanarFrame.Length.RightHandSide = "6.57162346521146"

Dim markId4 As NXOpen.Session.UndoMarkId = Nothing
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Text")

theSession.DeleteUndoMark(markId4, Nothing)

Dim markId5 As NXOpen.Session.UndoMarkId = Nothing
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Text")

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = textBuilder1.Commit()

theSession.DeleteUndoMark(markId5, Nothing)

theSession.SetUndoMarkName(markId1, "Text")

Dim expression3 As NXOpen.Expression = textBuilder1.FrameOnPath.Offset

Dim expression4 As NXOpen.Expression = textBuilder1.FrameOnPath.Length

Dim expression5 As NXOpen.Expression = textBuilder1.FrameOnPath.Height

Dim expression6 As NXOpen.Expression = textBuilder1.FrameOnPath.AnchorPosition.Expression

textBuilder1.Destroy()

Try
' Expression is still in use.
workPart.Expressions.Delete(expression2)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

Try
' Expression is still in use.
workPart.Expressions.Delete(expression1)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

plane1.DestroyPlane()

' ----------------------------------------------
' Menu: Insert->Curve->Text...
' ----------------------------------------------
Dim markId6 As NXOpen.Session.UndoMarkId = Nothing
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim textBuilder2 As NXOpen.Features.TextBuilder = Nothing
textBuilder2 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text)

Dim origin2 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim normal2 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim plane2 As NXOpen.Plane = Nothing
plane2 = workPart.Planes.CreatePlane(origin2, normal2, NXOpen.SmartObject.UpdateOption.WithinModeling)

textBuilder2.SectionPlane = plane2

Dim expression7 As NXOpen.Expression = Nothing
expression7 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression8 As NXOpen.Expression = Nothing
expression8 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim coordinates2 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim point2 As NXOpen.Point = Nothing
point2 = workPart.Points.CreatePoint(coordinates2)

textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder2.Type = NXOpen.Features.TextBuilder.Types.OnFace

textBuilder2.Script = NXOpen.Features.TextBuilder.ScriptOptions.Oem

textBuilder2.PlanarFrame.AnchorLocation = NXOpen.GeometricUtilities.RectangularFrameBuilder.AnchorLocationType.BottomCenter

textBuilder2.PlanarFrame.Length.RightHandSide = "6.57162346521146"

textBuilder2.PlanarFrame.Height.RightHandSide = "1"

textBuilder2.PlanarFrame.Shear.RightHandSide = "0"

textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"

textBuilder2.FrameOnPath.Offset.RightHandSide = "1.5"

textBuilder2.FrameOnPath.Length.RightHandSide = "2"

textBuilder2.FrameOnPath.Height.RightHandSide = "0.25"

textBuilder2.FrameOnPath.WScale = 273.90359431596545

textBuilder2.SelectFont("Modern", NXOpen.Features.TextBuilder.ScriptOptions.Oem)

textBuilder2.TextString = "J1234 BODY 1"

theSession.SetUndoMarkName(markId6, "Text Dialog")

Dim boundaryFaces2(-1) As NXOpen.Face
Dim faceTangentRule2 As NXOpen.FaceTangentRule = Nothing
faceTangentRule2 = workPart.ScRuleFactory.CreateRuleFaceTangent(face1, boundaryFaces2, 0.5)

Dim rules3(0) As NXOpen.SelectionIntentRule
rules3(0) = faceTangentRule2
textBuilder2.PlacementFaces.ReplaceRules(rules3, False)

textBuilder2.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)

Dim markId7 As NXOpen.Session.UndoMarkId = Nothing
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "section mark")

Dim markId8 As NXOpen.Session.UndoMarkId = Nothing
markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, Nothing)

Dim edgeTangentRule2 As NXOpen.EdgeTangentRule = Nothing
edgeTangentRule2 = workPart.ScRuleFactory.CreateRuleEdgeTangent(edge1, nullNXOpen_Edge, True, 0.5, False, False)

textBuilder2.OnFacePlacementProfile.AllowSelfIntersection(True)

Dim rules4(0) As NXOpen.SelectionIntentRule
rules4(0) = edgeTangentRule2
Dim helpPoint2 As NXOpen.Point3d = New NXOpen.Point3d(0.26931255602824633, -3.9337316854983571, 3.0782566011932024)
textBuilder2.OnFacePlacementProfile.AddToSection(rules4, edge1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint2, NXOpen.Section.Mode.Create, False)

theSession.DeleteUndoMark(markId8, Nothing)

theSession.DeleteUndoMark(markId7, Nothing)

textBuilder2.OnFacePlacementProfile.ReverseDirection()

textBuilder2.TextString = "H"

textBuilder2.TextString = "HH"

textBuilder2.TextString = "HH "

textBuilder2.TextString = "HH P"

textBuilder2.TextString = "HH P2"

textBuilder2.TextString = "HH P20"

textBuilder2.TextString = "HH P20"

textBuilder2.FrameOnPath.Offset.RightHandSide = "0.7"

textBuilder2.FrameOnPath.Offset.RightHandSide = "0.8"

textBuilder2.FrameOnPath.Offset.RightHandSide = "0.9"

textBuilder2.FrameOnPath.Length.RightHandSide = "2.47823906380607"

Dim markId9 As NXOpen.Session.UndoMarkId = Nothing
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Text")

theSession.DeleteUndoMark(markId9, Nothing)

Dim markId10 As NXOpen.Session.UndoMarkId = Nothing
markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Text")

Dim nXObject2 As NXOpen.NXObject = Nothing
nXObject2 = textBuilder2.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

theSession.SetUndoMarkName(markId6, "Text")

Dim expression9 As NXOpen.Expression = textBuilder2.FrameOnPath.Offset

Dim expression10 As NXOpen.Expression = textBuilder2.FrameOnPath.Length

Dim expression11 As NXOpen.Expression = textBuilder2.FrameOnPath.Height

Dim expression12 As NXOpen.Expression = textBuilder2.FrameOnPath.AnchorPosition.Expression

textBuilder2.Destroy()

Try
' Expression is still in use.
workPart.Expressions.Delete(expression8)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

Try
' Expression is still in use.
workPart.Expressions.Delete(expression7)
Catch ex As NXException
ex.AssertErrorCode(1050029)
End Try

plane2.DestroyPlane()

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

End Sub

Could someone help me please
Thank you

Could someone please help me to fix the code
I have to add the engraving to atleast 50 conponents in every job
this will save my time a lot at my work
Thanks

hi, I have posted a journal for engraving on the components in the below link. With some slight modifications you can use the code to suit your requirement.
http://www.nxjournaling.com/content/journal-engraving
Thanks, B

Balaji

Thank you