Edge Blend "Selection Stickiness" Removal

Hello,

I recorded the below journal just for creating two edge blends. Because an EDGE Blend need an EDGE and two connecting FACES, what would be the best practice to edit codes. I looked at the other 'face selection' and 'body section' posts from this site. But couldn't figure where to start for the below code. Need your kind help.


Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

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

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Insert->Detail Feature->Edge Blend...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim nullFeatures_Feature As Features.Feature = Nothing

If Not workPart.Preferences.Modeling.GetHistoryMode Then
Throw (New Exception("Create or edit of a Feature was recorded in History Mode but playback is in History-Free Mode."))
End If

Dim edgeBlendBuilder1 As Features.EdgeBlendBuilder
edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature)

Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit)

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

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

Dim expression3 As Expression
expression3 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression4 As Expression
expression4 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression5 As Expression
expression5 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression6 As Expression
expression6 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

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

Dim blendLimitsData1 As GeometricUtilities.BlendLimitsData
blendLimitsData1 = edgeBlendBuilder1.LimitsListData

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

Dim facePlaneSelectionBuilder1 As GeometricUtilities.FacePlaneSelectionBuilder
facePlaneSelectionBuilder1 = workPart.FacePlaneSelectionBuilderData.Create()

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

Dim expression9 As Expression
expression9 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression10 As Expression
expression10 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression11 As Expression
expression11 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

Dim expression12 As Expression
expression12 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

plane1.Evaluate()

Dim expression13 As Expression
expression13 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)

theSession.SetUndoMarkName(markId1, "Edge Blend Dialog")

Dim scaleAboutPoint1 As Point3d = New Point3d(-6.03079777943201, 0.995259358491706, 0.0)
Dim viewCenter1 As Point3d = New Point3d(6.03079777943199, -0.99525935849174, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint1, viewCenter1)

Dim scaleAboutPoint2 As Point3d = New Point3d(-4.82463822354561, 0.796207486793361, 0.0)
Dim viewCenter2 As Point3d = New Point3d(4.82463822354559, -0.796207486793397, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(1.25, scaleAboutPoint2, viewCenter2)

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

Dim seedEdges1(0) As Edge
Dim trimBody2_1 As Features.TrimBody2 = CType(workPart.Features.FindObject("TRIM BODY(29)"), Features.TrimBody2)

Dim edge1 As Edge = CType(trimBody2_1.FindObject("EDGE * 1 UNPARAMETERIZED_FEATURE(11) 1 {(-18.821234,4.875,0.25)(-11.0147836666667,4.875,0.25)(-3.2083333333333,4.875,0.25) UNPARAMETERIZED_FEATURE(11)}"), Edge)

seedEdges1(0) = edge1
Dim edgeMultipleSeedTangentRule1 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule1 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.01, True)

Dim rules1(0) As SelectionIntentRule
rules1(0) = edgeMultipleSeedTangentRule1
scCollector1.ReplaceRules(rules1, False)

Dim seedEdges2(1) As Edge
seedEdges2(0) = edge1
Dim brep1 As Features.Brep = CType(workPart.Features.FindObject("UNPARAMETERIZED_FEATURE(11)"), Features.Brep)

Dim edge2 As Edge = CType(brep1.FindObject("EDGE * 2 TRIM BODY(29) 1 {(-18.821234,4.875,-0)(-11.0147836666668,4.875,-0)(-3.2083333333336,4.875,-0) UNPARAMETERIZED_FEATURE(11)}"), Edge)

seedEdges2(1) = edge2
Dim edgeMultipleSeedTangentRule2 As EdgeMultipleSeedTangentRule
edgeMultipleSeedTangentRule2 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges2, 0.01, True)

Dim rules2(0) As SelectionIntentRule
rules2(0) = edgeMultipleSeedTangentRule2
scCollector1.ReplaceRules(rules2, False)

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

edgeBlendBuilder1.Tolerance = 0.001

edgeBlendBuilder1.AllInstancesOption = False

edgeBlendBuilder1.RemoveSelfIntersection = True

edgeBlendBuilder1.ConvexConcaveY = False

edgeBlendBuilder1.RollOverSmoothEdge = True

edgeBlendBuilder1.RollOntoEdge = True

edgeBlendBuilder1.MoveSharpEdge = True

edgeBlendBuilder1.TrimmingOption = False

edgeBlendBuilder1.OverlapOption = Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver

edgeBlendBuilder1.BlendOrder = Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst

edgeBlendBuilder1.SetbackOption = Features.EdgeBlendBuilder.Setback.SeparateFromCorner

Dim csIndex1 As Integer
csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, "0.1")

Dim feature1 As Features.Feature
feature1 = edgeBlendBuilder1.CommitFeature()

theSession.DeleteUndoMark(markId2, Nothing)

theSession.SetUndoMarkName(markId1, "Edge Blend")

workPart.FacePlaneSelectionBuilderData.Destroy(facePlaneSelectionBuilder1)

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

workPart.Expressions.Delete(expression13)

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

workPart.Expressions.Delete(expression10)

workPart.Expressions.Delete(expression12)

workPart.Expressions.Delete(expression9)

edgeBlendBuilder1.Destroy()

workPart.Expressions.Delete(expression2)

workPart.Expressions.Delete(expression6)

workPart.Expressions.Delete(expression1)

workPart.Expressions.Delete(expression4)

workPart.Expressions.Delete(expression5)

workPart.Expressions.Delete(expression3)

workPart.Expressions.Delete(expression7)

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

End Sub
End Module

It appears that your journal code creates an "edge blend" feature; this feature does not require faces to be specified (it will infer them from the specified edge). As such, I'm not 100% sure what you are asking for. Do you need a function that will allow the user to interactively select an edge?

Exactly. I wanted to have the modified code of the recorded code so that user can interactively select indefinite number of edges and input radius values. Thanks.

Regards,
MFJ

Why do you need a journal for that. you can use the Edge Blend UG Function and click on 'Apply" instead of 'Ok' to repeat the Edge Blend Function again and again until all the edges are 'blended'

Fab

The following journal illustrates one way to select model edges.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim selectedEdges As New List(Of Edge)
If SelectEdges("Select Edges", selectedEdges) = Selection.Response.Cancel Then
Return
End If

lw.WriteLine("selected edge tags")
For Each temp As Edge In selectedEdges
lw.WriteLine(temp.Tag.ToString)
Next

lw.Close()

End Sub

Function SelectEdges(ByVal prompt As String, ByRef theEdges As List(Of Edge)) As Selection.Response

Dim selObj() As TaggedObject
Dim theUI As UI = UI.GetUI
Dim title As String = "Select Edges"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
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.SelectTaggedObjects(prompt,
title, scope, selAction,
includeFeatures, keepHighlighted, selectionMask_array,
selObj)
If resp = Selection.Response.Ok Then
For Each tempEdge As Edge In selObj
theEdges.Add(tempEdge)
Next
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 immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

I needed a journal because it is a part of a process (step no 6 for example) I want to call using a macro to complete a whole 11-12 step process. I have used just macro for this Edge blend, but it does not work for some specific part. I could not find out why, but macro tries to keep the previous radius value used for the edge blend and try to apply it. Which is unexpected. So I decided to create a separate .Vb for the edge blend and call it using the Macro as an step. But I had to remove the 'Selection Stickiness' from the VB also and also let the user put the radius value through an input box. But I don't know the right way to edit the code. Thanks.

Regards,
MFJ