Trim Sketch Entities Example (VBA)
This example shows how to trim sketch entities.
'-------------------------------------------
'
' Preconditions: Sketch is open that has multiple
' sketch
lines.
'
' Postconditions: The first selected sketch line
' is
trimmed back to the second
' selected
intersecting sketch line.
'
'--------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSketchMgr As SldWorks.SketchManager
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
Set swSketchMgr = swModel.SketchManager
' Select the line to trim
boolstatus = swModelDocExt .SelectByID2("Line4",
"SKETCHSEGMENT", 0.007216080246914, 0.04301349794239, 0, True,
0, Nothing, 0)
' Trim the previously selected line to this line
boolstatus = swModelDocExt .SelectByID2("Line8",
"SKETCHSEGMENT", -0.03013774691358, 0.02518553497942, 0, True,
0, Nothing, 0)
swSketchMgr.SketchTrim
swSketchTrimTwoEntities, 0, 0
End Sub