Hide Table of Contents

Insert Swept-cut Thin-walled Feature Example (VBA)

This example shows how to create a swept-cut thin-walled feature.

' Preconditions: Verify that the specified part exists.
' Postconditions:
' 1. Creates a thin-walled swept-cut feature.
' 2. Examine the FeatureManager design tree and graphics area.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSketchMgr As SldWorks.SketchManager
Dim swSketchSegment As SldWorks.SketchSegment
Dim swFeature As SldWorks.Feature
Dim swPathFeat As SldWorks.Feature
Dim swFeatureMgr As SldWorks.FeatureManager
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swSweepFeatureData As SldWorks.SweepFeatureData
Dim swSweep As SldWorks.SweepFeatureData
Dim swProfileObj As Object
Dim swProfileBody As SldWorks.Body2
Dim swPathFeature As SldWorks.Feature
Dim sketchLines As Variant
Dim status As Boolean
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.OpenDoc6("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\api\sweepcutextrude.SLDPRT", 1, 0, "", longstatus, longwarnings)

    boolstatus = swModel.Extension.SelectByID2("Sketch2", "SKETCH", 0.01948983274156, -0.02564816935317, 0, False, 1, Nothing, 0)
    boolstatus = swModel.Extension.SelectByID2("Sketch3", "SKETCH", -0.03797488317814, -0.02133214444164, 0, True, 4, Nothing, 0)

    Set swSweep = swModel.FeatureManager.CreateDefinition(swFmSweepCut)

    swSweep.TwistControlType = 0
    swSweep.PathAlignmentType = 0
    swSweep.ThinFeature = True
    swSweep.SetWallThickness True, 0.001 'Meters in Direction 1
    swSweep.SetWallThickness False, 0.001 'Meters in Direction 2
    swSweep.ThinWallType = 3 '2 Directions
    swSweep.TangentPropagation = False
    swSweep.AlignWithEndFaces = True
    swSweep.MaintainTangency = False
    swSweep.AdvancedSmoothing = False
    swSweep.StartTangencyType = 0
    swSweep.EndTangencyType = 0
    swSweep.FeatureScope = True
    swSweep.AutoSelect = True
    swSweep.SetTwistAngle 0#
    swSweep.MergeSmoothFaces = True
    swSweep.AssemblyFeatureScope = True
    swSweep.AutoSelectComponents = True
    swSweep.PropagateFeatureToParts = False
    swSweep.CircularProfile = False
    swSweep.CircularProfileDiameter = 0#

    Set swPathFeat = swModel.FeatureManager.CreateFeature(swSweep)

End Sub

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Insert Swept-cut Thin-walled Feature Example (VBA)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2018 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.