Files
Code
Module: mMain
'Demonstrates how to use the Split feature.
'Preconditions: have a part open that is bisected by the Front Plane
'Results: part is split using Front Plane. Bodies are not consumed _
and are not saved.
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.Extension.SelectByID2 "Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0
'Get the bodies that will result from the split using IFeatureManager::PreSplitBody
Dim bodyArray As Variant
bodyArray = swModel.FeatureManager.PreSplitBody()
swModel.ClearSelection2 True
'The vertex and body names arrays must be of the same size as bodyArray, even if
' the elements are Nothing or Empty
Dim swVertices() As SldWorks.Vertex
ReDim swVertices(UBound(bodyArray))
Dim strBodyNames() As String
ReDim strBodyNames(UBound(bodyArray))
'Use IFeatureManager::PostSplitBody to create the split
swModel.FeatureManager.PostSplitBody bodyArray, False, swVertices, strBodyNames
End Sub