Extends a surface along its natural boundaries or fills interior surface holes, optionally trimming outside these boundaries or holes.
'VBA
'This example creates a planar polygonal surface, untrims (extends) the surface outside the selected face edges,
'and trims (removes) the surface inside the selected face edges.
'=======================================================================
'Preconditions: Ensure that the specified template exists.
'
'Postconditions:
'1. Creates Surface-Plane1.
'2. Creates Surface-Untrim1 by untrimming outside all edges of the selected face, not merging with the original part, and trimming inside all edges of the selected face.
'3. Click on Surface-Untrim1. The untrimmed areas are in green.
'========================================================================
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim skSegment As SldWorks.SketchSegment
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Dim swSheetWidth As Double
swSheetWidth = 0
Dim swSheetHeight As Double
swSheetHeight = 0
Set Part = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2024\templates\Part.prtdot", 0, swSheetWidth, swSheetHeight)
Set swPart = Part
Set Part = swApp.ActiveDoc
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", -4.90383108306059E-02, 3.86835343160318E-02, 3.91373764799244E-03, False, 0, Nothing, 0)
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.CreateLine(-0.035002, 0.035119, 0#, 0.025668, 0.036519, 0#)
Set skSegment = Part.SketchManager.CreateLine(0.025663, 0.036519, 0#, 0.025201, -0.016451, 0#)
Set skSegment = Part.SketchManager.CreateLine(0.025201, -0.016451, 0#, -0.068137, -0.018551, 0#)
Set skSegment = Part.SketchManager.CreateLine(-0.068137, -0.018551, 0#, -0.067204, 0.026718, 0#)
Set skSegment = Part.SketchManager.CreateLine(-0.067204, 0.026713, 0#, -0.036169, 0.026251, 0#)
Set skSegment = Part.SketchManager.CreateLine(-0.036169, 0.026251, 0#, -0.035002, 0.035119, 0#)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.SelectionManager.EnableContourSelection = True
boolstatus = Part.Extension.SelectByID2("Sketch1", "SKETCHREGION", 2.26345552080154E-02, -0.013184045043844, 0, True, 1, Nothing, 0)
boolstatus = Part.InsertPlanarRefSurface()
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByRay(-4.08355377464196E-02, 1.83176555033939E-02, 0, 0, 0, -1, 7.93376161930438E-04, 2, True, 0, 0)
Part.FeatureManager.InsertUntrimSurface2 0, 2, 0, False, True
Part.SelectionManager.EnableContourSelection = False
End Sub