Hide Table of Contents

Insert Swept-cut Feature Using Circular Profile Example (VBA)

This example shows how to create a swept-cut feature using a circular profile and get its properties.

'---------------------------------------------------------------------------
' Preconditions:
' 1. Verify that the part exists.
' 2. Open an Immediate window.
'
' Postconditions:
' 1. Opens the part.
' 2. Selects an edge on the part.
' 3. Creates a cut-sweep feature using a circular profile.
' 4. Accesses the cut-sweep feature.
' 5. Changes the diameter of the circular profile.
' 6. Examine the Immediate window, FeatureManager
'    design tree, and graphics area.
'
' NOTE: Because the part is used elsewhere, do not save changes.
'---------------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swPathFeat As SldWorks.Feature
Dim swFeatureManager As SldWorks.FeatureManager
Dim swSweep As SldWorks.SweepFeatureData
Dim status As Boolean
Dim errors As Long
Dim warnings As Long

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.OpenDoc6("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\api\block20.sldprt", 1, 0, "", errors, warnings)
    Set swModelDocExt = swModel.Extension    
    'Select an edge for the circular profile
    status = swModelDocExt.SelectByID2("", "EDGE", -3.72983839416747E-02, 3.93904284381961E-02, 4.95042874504179E-02, True, 4, Nothing, 0)
    Set swFeatureManager = swModel.FeatureManager    

    Set swSweep = swModel.FeatureManager.CreateDefinition(swFmSweepCut)

    swSweep.TangentPropagation = False
    swSweep.AlignWithEndFaces = True
    swSweep.TwistControlType = 0
    swSweep.MaintainTangency = False
    swSweep.AdvancedSmoothing = False
    swSweep.StartTangencyType = 0
    swSweep.EndTangencyType = 0
    swSweep.PathAlignmentType = 0
    swSweep.FeatureScope = True
    swSweep.AutoSelect = True
    swSweep.MergeSmoothFaces = True
    swSweep.CircularProfile = True
    swSweep.CircularProfileDiameter = 0.008

    Set swPathFeat = swModel.FeatureManager.CreateFeature(swSweep)
 
    Set swSweep = swPathFeat.GetDefinition
    status = swSweep.AccessSelections(swModel, Nothing)
    Debug.Print "Using a circular profile? " & swSweep.CircularProfile
    Debug.Print "Original size of circular profile = " & swSweep.CircularProfileDiameter
    swSweep.CircularProfileDiameter = 0.003
    Debug.Print "Modified size of circular profile = " & swSweep.CircularProfileDiameter  
    swPathFeat.ModifyDefinition swSweep, swModel, Nothing   

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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Insert Swept-cut Feature Using Circular Profile Example (VBA)
*Comment:  
*   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:



x

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
x

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.