Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all articles
Browse latest Browse all 787

Edge Blend "Selection Stickiness" Removal

$
0
0

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

Viewing all articles
Browse latest Browse all 787

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>