Journal for Engraving

Hello All,
Below journal creates the Engraving on the part body by extracting details from part attributes such as Description, Part number (removed the last 5 characters of the string from the part number for my requirement)& Weight.

' NX 12.0.1.7
' Journal created by Balaji_Sampath03 on Tue Jul 21 20:07:10 2020 India Standard Time
'**************************************************************************************
'This Journal creates the Engraving on the NX part with attribute info such as
'1> Description
'2> Part Number (last 4 characters of the string from part number is removed) and
'3> Weight
'This Journal does not have any exception to catch any errors
'Has option to invert the direction of the Offset curve before the final extrude option
'***************************************************************************************
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF

Module NXJournal

Dim theUfSession As UFSession = UFSession.GetUFSession()
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 lw As ListingWindow = theSession.ListingWindow
Dim theUI As UI = UI.GetUI()

Sub Main (ByVal args() As String)

Dim attDesc As String = Nothing
Dim attPartNum As String = Nothing
Dim attWeight As Double = Nothing
Dim attributeInfo As NXObject.AttributeInformation

' -------------------
' GET USER ATTRIBUTES
' -------------------

If workPart.HasUserAttribute("DESCRIPTION", NXObject.AttributeType.Any, -1) Then
attributeInfo = workPart.GetUserAttribute("Description", NXObject.AttributeType.String, -1)
attDesc = attributeInfo.StringValue
Else
lw.WriteLine("Attribute 'DESCRIPTION' is not present")
End If

If workPart.HasUserAttribute("Weight", NXObject.AttributeType.Any, -1) Then
Dim aInfo As NXObject.AttributeInformation
aInfo = workPart.GetUserAttribute("Weight", NXObject.AttributeType.Any, -1)
attWeight = aInfo.StringValue
Else
lw.WriteLine("Attribute 'Weight' is not present")
attWeight = " "
End If

attPartnum = workPart.Name

' -----------------------------------------------------------------
' CREATE FEATURE GROUP "ENGRAVE TEXT" AND MAKE FEATURE GROUP ACTIVE
' -----------------------------------------------------------------

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Feature Groups")

Dim activatefeaturegroupwithrollback1 As Boolean = Nothing
activatefeaturegroupwithrollback1 = theSession.Preferences.Modeling.ActivateFeatureGroupWithRollback

Dim featuresToGroup As Tag() = Nothing
Dim theFeatureGroupTag As Tag = Nothing
theUfSession.Modl.CreateSetOfFeature("ENGRAVE TEXT", featuresToGroup, 0, 1, theFeatureGroupTag)

For Each myFeature As Features.Feature In workPart.Features
If TypeOf (myFeature) Is NXOpen.Features.FeatureGroup Then
If myFeature.FeatureType = "FSET" And myFeature.Name = "ENGRAVE TEXT" Then
myFeature.MakeCurrentFeature()
myFeature.SetGroupActive(True)
End If
End If
Next

' ---------------------------------------------------
' SET PARAMETERS FOR CURVE SEL AND FACE OFFSET METHOD
' ---------------------------------------------------

Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing

Dim aOCSBuilder1 As NXOpen.Features.AOCSBuilder = Nothing
aOCSBuilder1 = workPart.Features.CreateAocsBuilder(nullNXOpen_Features_Feature)

Dim lawBuilder1 As NXOpen.GeometricUtilities.LawBuilder = Nothing
lawBuilder1 = aOCSBuilder1.Law

Dim alongSpineBuilder1 As NXOpen.GeometricUtilities.AlongSpineBuilder = Nothing
alongSpineBuilder1 = lawBuilder1.AlongSpineData

Dim unit1 As NXOpen.Unit = Nothing
unit1 = aOCSBuilder1.FilletRadius.Units

Dim curveFitData1 As NXOpen.GeometricUtilities.CurveFitData = Nothing
curveFitData1 = aOCSBuilder1.CurveFitData

Dim nullNXOpen_ScCollector As NXOpen.ScCollector = Nothing

aOCSBuilder1.FaceCollector = nullNXOpen_ScCollector

aOCSBuilder1.OffsetDistType = NXOpen.Features.AOCSBuilder.OffsetDistanceType.Constant
aOCSBuilder1.OffsetDirectionOption = NXOpen.Features.AOCSBuilder.OffsetDirection.NormalToCurve
aOCSBuilder1.OffsetMode = NXOpen.Features.AOCSBuilder.OffsetType.Tangential
aOCSBuilder1.TrimMethod = NXOpen.Features.AOCSBuilder.Trim.WithinSection
aOCSBuilder1.ExtendMethod = NXOpen.Features.AOCSBuilder.Extend.WithinSection
aOCSBuilder1.TrimToFaceEdgesOption = False
aOCSBuilder1.ExtendToFaceOption = NXOpen.Features.AOCSBuilder.ExtendToFace.Boundary
aOCSBuilder1.RemoveSelfIntersections = True
aOCSBuilder1.AssociativeOutputOption = True
aOCSBuilder1.LawStringFlip = False
aOCSBuilder1.SplitCurveOption = True
aOCSBuilder1.OffsetDirectionOption = NXOpen.Features.AOCSBuilder.OffsetDirection.NormalToCurve

aOCSBuilder1.FilletOption = NXOpen.Features.AOCSBuilder.FilletOptions.NoFillet
aOCSBuilder1.CurveOffsetType = NXOpen.Features.AOCSBuilder.CurveOffsetTypes.Value

Dim nullNXOpen_Point As NXOpen.Point = Nothing

aOCSBuilder1.ThroughPoint = nullNXOpen_Point

Dim objectList1 As NXOpen.ObjectList = Nothing
objectList1 = alongSpineBuilder1.SpinePointList
objectList1.Clear(NXOpen.ObjectList.DeleteOption.Delete)

Dim origin1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim vector1 As NXOpen.Vector3d = New NXOpen.Vector3d(1.0, 0.0, 0.0)
Dim direction1 As NXOpen.Direction = Nothing
direction1 = workPart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling)

aOCSBuilder1.ProjectPlaneNormal = direction1

Dim section1 As NXOpen.Section = Nothing
section1 = workPart.Sections.CreateSection(0.0094999999999999998, 0.01, 0.5)

Dim nullNXOpen_Section As NXOpen.Section = Nothing

Dim expressionSectionSet1 As NXOpen.ExpressionSectionSet = Nothing
expressionSectionSet1 = workPart.CreateExpressionSectionSet(nullNXOpen_Section, "2", "Length", 0)

expressionSectionSet1.ItemFlipFlag = True
aOCSBuilder1.Offsets.Append(expressionSectionSet1)

section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves)

' ------------------------
' SELECT CURVE TO OFFSET
' ------------------------

Dim pickEdge As Edge

If SelectEdge("Select Edge", pickEdge) = Selection.Response.Cancel Then
Return
End If

Dim edges1(0) As NXOpen.Edge
edges1(0) = pickEdge

Dim edgeDumbRule1 As NXOpen.EdgeDumbRule = Nothing
edgeDumbRule1 = workPart.ScRuleFactory.CreateRuleEdgeDumb(edges1)

section1.AllowSelfIntersection(False)

Dim rules1(0) As NXOpen.SelectionIntentRule
rules1(0) = edgeDumbRule1
Dim nullNXOpen_NXObject As NXOpen.NXObject = Nothing

Dim helpPoint1 As NXOpen.Point3d = New NXOpen.Point3d(-51.890018880214939, -40.000000000000043, 10.0)
section1.AddToSection(rules1, pickEdge, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False)

expressionSectionSet1.Section = section1

' ----------------------
' SELECT FACE FOR OFFSET
' ----------------------

Dim scCollector1 As NXOpen.ScCollector = Nothing
scCollector1 = workPart.ScCollectors.CreateCollector()

Dim pickFace As Face
SelectAFace("select a face", pickFace)

Dim faces1(0) As NXOpen.Face
faces1(0) = pickFace

Dim faceDumbRule1 As NXOpen.FaceDumbRule = Nothing
faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)
Dim rules2(0) As NXOpen.SelectionIntentRule
rules2(0) = faceDumbRule1
scCollector1.ReplaceRules(rules2, False)

aOCSBuilder1.FaceCollector = scCollector1
aOCSBuilder1.UpdateFaces()

Dim feature1 As NXOpen.Features.Feature = Nothing
feature1 = aOCSBuilder1.CommitFeature()
aOCSBuilder1.Destroy()

' -------------------------------------------
' INSERT TEXT 1 AND SEL OFFSET CURVE FOR TEXT
' -------------------------------------------

Dim nullNXOpen_Features_Text As NXOpen.Features.Text = Nothing

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

textBuilder1.TextString = ("WEIGHT: " & attWeight.ToString("0.00") & " kg")
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"
textBuilder1.Type = NXOpen.Features.TextBuilder.Types.OnFace
textBuilder1.PlanarFrame.Shear.RightHandSide = "0"
textBuilder1.FrameOnPath.AnchorLocation = NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "5"
textBuilder1.FrameOnPath.Height.RightHandSide = "5"
textBuilder1.PrintMarkThickness.RightHandSide = "1"
textBuilder1.FrameOnPath.WScale = 100.0
textBuilder1.FrameOnPath.Offset.RightHandSide = "0"
textBuilder1.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western)

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

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

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

Dim features1(0) As NXOpen.Features.Feature
Dim aOCS1 As NXOpen.Features.AOCS = CType(feature1, NXOpen.Features.AOCS)

features1(0) = aOCS1
Dim line1 As NXOpen.Line = CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line)

Dim nullNXOpen_Curve As NXOpen.Curve = Nothing

Dim curveFeatureTangentRule1 As NXOpen.CurveFeatureTangentRule = Nothing
curveFeatureTangentRule1 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features1, line1, nullNXOpen_Curve, False, 0.01, 0.5)

textBuilder1.OnFacePlacementProfile.AllowSelfIntersection(True)

Dim rules4(0) As NXOpen.SelectionIntentRule
rules4(0) = curveFeatureTangentRule1
Dim helpPoint2 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder1.OnFacePlacementProfile.AddToSection(rules4, line1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint2, NXOpen.Section.Mode.Create, False)

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

textBuilder1.Destroy()

' -------------------------------------------
' INSERT TEXT 2 AND SEL OFFSET CURVE FOR TEXT
' -------------------------------------------

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

Dim trimmedAttPartNum As String = attPartnum.Remove( attPartnum.Length - 5 )

textBuilder2.TextString = trimmedAttPartNum
textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"
textBuilder2.Type = NXOpen.Features.TextBuilder.Types.OnFace
textBuilder2.PlanarFrame.Shear.RightHandSide = "0"
textBuilder2.FrameOnPath.AnchorLocation = NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide = "5"
textBuilder2.FrameOnPath.Height.RightHandSide = "5"
textBuilder2.PrintMarkThickness.RightHandSide = "1"
textBuilder2.FrameOnPath.WScale = 100.0
textBuilder2.FrameOnPath.Offset.RightHandSide = "7"
textBuilder2.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western)

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

Dim rules5(0) As NXOpen.SelectionIntentRule
rules5(0) = faceTangentRule1
textBuilder2.PlacementFaces.ReplaceRules(rules5, False)

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

Dim features2(0) As NXOpen.Features.Feature
features2(0) = aOCS1
Dim line3 As NXOpen.Line = CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line)

Dim curveFeatureTangentRule2 As NXOpen.CurveFeatureTangentRule = Nothing
curveFeatureTangentRule2 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features2, line3, nullNXOpen_Curve, False, 0.01, 0.5)

textBuilder2.OnFacePlacementProfile.AllowSelfIntersection(True)

Dim rules6(0) As NXOpen.SelectionIntentRule
rules6(0) = curveFeatureTangentRule1
Dim helpPoint3 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder2.OnFacePlacementProfile.AddToSection(rules6, line3, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint3, NXOpen.Section.Mode.Create, False)

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

textBuilder2.Destroy()

' -------------------------------------------
' INSERT TEXT 3 AND SEL OFFSET CURVE FOR TEXT
' -------------------------------------------

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

textBuilder3.TextString = attDesc

textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50"
textBuilder3.Type = NXOpen.Features.TextBuilder.Types.OnFace
textBuilder3.PlanarFrame.Shear.RightHandSide = "0"
textBuilder3.FrameOnPath.AnchorLocation = NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide = "5"
textBuilder3.FrameOnPath.Height.RightHandSide = "5"
textBuilder3.PrintMarkThickness.RightHandSide = "1"
textBuilder3.FrameOnPath.WScale = 100.0
textBuilder3.FrameOnPath.Offset.RightHandSide = "14"
textBuilder3.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western)

Dim boundaryFaces3(-1) As NXOpen.Face
Dim faceTangentRule3 As NXOpen.FaceTangentRule = Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces3, 0.5)

Dim rules7(0) As NXOpen.SelectionIntentRule
rules7(0) = faceTangentRule1
textBuilder3.PlacementFaces.ReplaceRules(rules7, False)

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

Dim features3(0) As NXOpen.Features.Feature
features3(0) = aOCS1
Dim line4 As NXOpen.Line = CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line)

Dim curveFeatureTangentRule3 As NXOpen.CurveFeatureTangentRule = Nothing
curveFeatureTangentRule3 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features3, line4, nullNXOpen_Curve, False, 0.01, 0.5)

textBuilder3.OnFacePlacementProfile.AllowSelfIntersection(True)

Dim rules8(0) As NXOpen.SelectionIntentRule
rules8(0) = curveFeatureTangentRule3
Dim helpPoint4 As NXOpen.Point3d = New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder3.OnFacePlacementProfile.AddToSection(rules8, line4, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint4, NXOpen.Section.Mode.Create, False)

Dim nXObject3 As NXOpen.NXObject = Nothing
nXObject3 = textBuilder3.Commit()

textBuilder3.Destroy()

' ------------------------------
' REVERSE OFFSET CURVE DIRECTION
' ------------------------------
Dim answer As Integer = theUI.NXMessageBox.Show("Offset Curve Direction",
NXOpen.NXMessageBox.DialogType.Question, "Change Offset Curve Direction..?")

If answer = 1 Then

Dim editWithRollbackManager1 As NXOpen.Features.EditWithRollbackManager = Nothing
editWithRollbackManager1 = workPart.Features.StartEditWithRollbackManager(aOCS1, markId1)

Dim aOCSBuilder2 As NXOpen.Features.AOCSBuilder = Nothing
aOCSBuilder2 = workPart.Features.CreateAocsBuilder(aOCS1)

Dim taggedObject2 As NXOpen.TaggedObject = Nothing
taggedObject2 = aOCSBuilder2.Offsets.FindItem(0)

Dim expressionSectionSet2 As NXOpen.ExpressionSectionSet = CType(taggedObject2, NXOpen.ExpressionSectionSet)

section1.ReverseDirectionOfLoop(0)

Dim flipDirection1 As Boolean = Nothing
flipDirection1 = aOCSBuilder2.UpdateSectionData(section1)

Dim feature2 As NXOpen.Features.Feature = Nothing
feature2 = aOCSBuilder2.CommitFeature()

editWithRollbackManager1.UpdateFeature(False)
editWithRollbackManager1.Stop()
editWithRollbackManager1.Destroy()
End If

' ----------------------------------------------
' SELECT TEXT TO EXTRUDE & BODY TO SUBTRACT FROM
' ----------------------------------------------

Dim EdgeOBJ as Edge = pickEdge
Dim text2SubFrom As Body = EdgeOBJ.GetBody()

Dim extrudeBuilder1 As NXOpen.Features.ExtrudeBuilder = Nothing
extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature)

Dim section5 As NXOpen.Section = Nothing
section5 = workPart.Sections.CreateSection(0.0094999999999999998, 0.01, 0.5)

extrudeBuilder1.Section = section5

Dim targetBodies1(0) As NXOpen.Body
Dim nullNXOpen_Body As NXOpen.Body = Nothing
targetBodies1(0) = nullNXOpen_Body

extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1)
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "0.5"
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = "-0.5"
extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract

Dim targetBodies2(0) As NXOpen.Body

targetBodies2(0) = text2SubFrom

extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies2)

Dim smartVolumeProfileBuilder1 As NXOpen.GeometricUtilities.SmartVolumeProfileBuilder = Nothing
smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile

Dim features4(0) As NXOpen.Features.Feature
Dim text1 As NXOpen.Features.Text = CType(nXObject1, NXOpen.Features.Text)
features4(0) = text1
Dim features5(0) As NXOpen.Features.Feature
Dim text2 As NXOpen.Features.Text = CType(nXObject2, NXOpen.Features.Text)
features5(0) = text2
Dim features6(0) As NXOpen.Features.Feature
Dim text3 As NXOpen.Features.Text = CType(nXObject3, NXOpen.Features.Text)
features6(0) = text3

Dim curveFeatureRule1 As NXOpen.CurveFeatureRule = Nothing
curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features4)
Dim curveFeatureRule2 As NXOpen.CurveFeatureRule = Nothing
curveFeatureRule2 = workPart.ScRuleFactory.CreateRuleCurveFeature(features5)
Dim curveFeatureRule3 As NXOpen.CurveFeatureRule = Nothing
curveFeatureRule3 = workPart.ScRuleFactory.CreateRuleCurveFeature(features6)

Dim rules9(0) As NXOpen.SelectionIntentRule
rules9(0) = curveFeatureRule1
Dim helpPoint5 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules9, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint5, NXOpen.Section.Mode.Create, False)

Dim rules10(0) As NXOpen.SelectionIntentRule
rules10(0) = curveFeatureRule2
Dim helpPoint6 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules10, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint6, NXOpen.Section.Mode.Create, False)

Dim rules11(0) As NXOpen.SelectionIntentRule
rules11(0) = curveFeatureRule3
Dim helpPoint7 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules11, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint7, NXOpen.Section.Mode.Create, False)

Dim origin3 As NXOpen.Point3d = New NXOpen.Point3d(-46.124198330506573, 7.7841263299248453, 10.0)
Dim vector2 As NXOpen.Vector3d = New NXOpen.Vector3d(0.0, 0.0, 1.0)
Dim direction2 As NXOpen.Direction = Nothing
direction2 = workPart.Directions.CreateDirection(origin3, vector2, NXOpen.SmartObject.UpdateOption.WithinModeling)

extrudeBuilder1.Direction = direction2
extrudeBuilder1.ParentFeatureInternal = False

Dim feature3 As NXOpen.Features.Feature = Nothing
feature3 = extrudeBuilder1.CommitFeature()

extrudeBuilder1.Destroy()

'--------------------
'Clear Selection List
'--------------------

Dim partCleanup As NXOpen.PartCleanup = Nothing
partCleanup = theSession.NewPartCleanup()
partCleanup.TurnOffHighlighting = True
partCleanup.DoCleanup()
partCleanup.Dispose()

End Sub

Function SelectAFace(ByVal prompt As String, ByRef selObj As Face) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "pickFace"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = True
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Function SelectEdge(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "pickEdge"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = True
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------

End Function

End Module

Thank you so much Balaji_Sampath
I will give it a short

hi NXJournaling, in the above Journal, I have the option to flip the offset curve direction if in case the text for extrude goes outside the solid body. Every time I change the offset curve direction, the extrude feature is going outside the feature group. But when I don't flip the curve direction, the extrude feature is coming within the feature group. What could be wrong with the code. Could you please help in fixing the code. Thanks, B

Balaji

Hi Balaji,
Please see the below error when I am running the above journal
Could you please assist me

Error

Line217:'PrintMarkThickness' is not a member of NXOpen.Features.TextBuilder'.
Line271:'PrintMarkThickness' is not a member of NXOpen.Features.TextBuilder'.
Line320:'PrintMarkThickness' is not a member of NXOpen.Features.TextBuilder'.
Line 492:Warning:'Public Function SelectObject(message As String, title As String,
scope As NXOpen.SelectionScope, action As
NXOpen.Selection.SelectionAction, includeFeatures As Boolean, keep Highlighted As
Boolean, maskArray() As NXOpen.Selection.MaskTriple, ByRef object As
NXOpen.NXOject, ByRef cursor As NXOpen.Point3d) As NXOpen.Selection.Response'
is obsolete: 'Deprecated in NX8.0.0. Use Selection.SelectTaggedObject instead'.

Thank you

What version of NX are you using? I suspect that Balaji is using a newer version of NX than you and is taking advantage of new functions not available in your version.

The SelectObject warning (line 492) is telling us that the code should be corrected to use the SelectTaggedObject method instead. The SelectObject function has been deprecated for several versions now. However, the rest of the errors appear to be calls to functions not available in your current version.

Hi,
I am using the same version of NX what Balaji is using
Is there any way we can fix this error please?
Or am I missing any selections before I trigger the Journal
Help will be appreciated
Thank you