I can specify tangency for a Boundary Surface feature through the GUI, but not through the API (SW 2023). The macro below creates a Boundary Surface feature using an edge and a sketch in direction 1, and two sketches in direction 2. I use SetNetBlendCurveData to specify that the surface should be tangent to the adjacent surface at the edge, but it does not do anything. The tangency condition shows as "None" in the feature editor.
Am I doing something wrong?
Dim swApp As SldWorks.SldWorks Dim swModel As ModelDoc2 Dim swSketchMgr As SketchManager Dim swFeatMgr As FeatureManager Dim swSketchSegment As SketchSegment Sub main() Set swApp = Application.SldWorks ' Create new part Set swModel = swApp.NewPart Set swSketchMgr = swModel.SketchManager Set swFeatMgr = swModel.FeatureManager ' Select Front Plane and create sketch swModel.Extension.SelectByID2 "Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0 swSketchMgr.InsertSketch True ' Draw a rectangle (100mm x 50mm) bottom left at origin ' swSketchMgr.CreateCornerRectangle 0, 0, 0, 0.1, 0.05, 0 Dim centerX As Double: centerX = 0.05 ' Midpoint of top edge Dim centerY As Double: centerY = 0.025 ' Center of rectangle Dim radius As Double: radius = 0.03 Dim angle As Double: angle = 30 * (3.14159265359 / 180) ' 30 degrees in radians ' Start and end points of arc (60 degrees total) Dim startX As Double: startX = centerX + radius * Sin(angle) Dim startY As Double: startY = centerY + radius * Cos(angle) Dim endX As Double: endX = centerX + radius * Sin(-angle) Dim endY As Double: endY = centerY + radius * Cos(-angle) swSketchMgr.CreateArc centerX, centerY, 0, startX, startY, 0, endX, endY, 0, 1 ' Coouterclockwise arc ' Close the crescent shape with a line swSketchMgr.CreateLine endX, endY, 0, startX, startY, 0 swSketchMgr.InsertSketch True swModel.ClearSelection2 True boolstatus = swModel.Extension.SelectByID2("Sketch1", "SKETCH", 5.87644585700619E-02, 0.050824615470025, -5.85795561566647E-04, False, 1, Nothing, 0) boolstatus = swModel.InsertPlanarRefSurface() swModel.ClearSelection2 True Dim swSurfFeat As Feature Dim swSurfBody As Body2 Dim edges As Variant Dim crescentEdge As edge Dim i As Integer Set swSurfFeat = swModel.FeatureByPositionReverse(0) edges = swSurfFeat.IGetBody2().GetEdges For i = LBound(edges) To UBound(edges) Dim e As edge Set e = edges(i) Dim curve As curve Set curve = e.GetCurve() If curve.IsCircle Then Set crescentEdge = e Exit For End If Next ' === 3D Arcs Going Upward (YZ Plane) === ' 1st sketch (arc 1) swSketchMgr.Insert3DSketch True Dim arc1Sketch As Feature Set arc1Sketch = swModel.FeatureByPositionReverse(0) Dim R As Double: R = 0.0025 Dim arcAngleDeg3D As Double: arcAngleDeg3D = 90 Dim arcAngleRad3D As Double: arcAngleRad3D = arcAngleDeg3D * (3.14159265359 / 180) ' Start 3D Arc (left end of crescent) Dim arc1 As SketchSegment Dim x1 As Double: x1 = startX Dim y1 As Double: y1 = startY Dim z1 As Double: z1 = 0 Dim y1mid As Double: y1mid = y1 + R * Sin(arcAngleRad3D / 2) Dim z1mid As Double: z1mid = z1 + R * (1 - Cos(arcAngleRad3D / 2)) Dim y1end As Double: y1end = y1 + R * Sin(arcAngleRad3D) Dim z1end As Double: z1end = z1 + R * (1 - Cos(arcAngleRad3D)) Set arc1 = swSketchMgr.Create3PointArc(x1, y1, z1, x1, y1end, z1end, x1, y1mid, z1mid) swSketchMgr.Insert3DSketch False ' 2nd sketch (arc 2) swSketchMgr.Insert3DSketch True Dim arc2Sketch As Feature Set arc2Sketch = swModel.FeatureByPositionReverse(0) ' End 3D Arc (right end of crescent) Dim arc2 As SketchSegment Dim x2 As Double: x2 = endX Dim y2 As Double: y2 = endY Dim z2 As Double: z2 = 0 Dim y2mid As Double: y2mid = y2 + R * Sin(arcAngleRad3D / 2) Dim z2mid As Double: z2mid = z2 + R * (1 - Cos(arcAngleRad3D / 2)) Dim y2end As Double: y2end = y2 + R * Sin(arcAngleRad3D) Dim z2end As Double: z2end = z2 + R * (1 - Cos(arcAngleRad3D)) Set arc2 = swSketchMgr.Create3PointArc(x2, y2, z2, x2, y2end, z2end, x2, y2mid, z2mid) swSketchMgr.Insert3DSketch False ' 3rd sketch (Connecting line between tops of arcs) swSketchMgr.Insert3DSketch True Dim lineSketch As Feature Set lineSketch = swModel.FeatureByPositionReverse(0) Dim line As SketchSegment Set line = swSketchMgr.CreateLine(x1, y1end, z1end, x2, y2end, z2end) swSketchMgr.Insert3DSketch False ' Select curves: direction 1: crescent arc (edge), connecting line ' direction 2: two 3D arcs swModel.ClearSelection2 True ' Select crescent edge Dim selDataCrescent As SelectData Set selDataCrescent = swModel.SelectionManager.CreateSelectData selDataCrescent.Mark = 8193 boolstatus = crescentEdge.Select4(True, selDataCrescent) boolstatus = lineSketch.Select2(True, 16385) boolstatus = arc1Sketch.Select2(True, 12290) boolstatus = arc2Sketch.Select2(True, 24578) swFeatMgr.SetNetBlendCurveData 0, 0, 3, 0, 1, True ' Make 1st curve of the first direction tangent to the adjacent face Dim blendFeature As Feature Set blendFeature = swFeatMgr.InsertNetBlend2(2, 2, 2, False, 1, False, True, True, True, False, -1, -1, False, -1, False, False, -1, False, -1, False, False) End Sub
Thanks!