Hide Table of Contents

Get Properties of Sweep Feature Example (VBA)

This example shows how to get the properties of a sweep feature.

 

'--------------------------------------

'

' Preconditions:

'            (1) Model document is open.

'            (2) Sweep feature is selected.

'

' Postconditions: None

'

'---------------------------------------

Option Explicit

Public Enum swTangencyType_e

    swTangencyNone = 0

    swTangencyNormalToProfile = 1

    swTangencyDirectionVector = 2

    swTangencyAllFaces = 3

End Enum

'SweepFeatureData:: ThinWallType

'    0 = One Direction

'    1 = One Direction Reverse

'    2 = MidPlane

'    3 = Two Direction

Public Enum swTwistControlType_e

    swTwistControlFollowPath = 0

    swTwistControlKeepNormalConstant = 1

    swTwistControlFollowPathFirstGuideCurve = 2

    swTwistControlFollowFirstSecondGuideCurves = 3

End Enum

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swFeat                  As SldWorks.feature

    Dim swSweep                 As SldWorks.sweepfeaturedata

    

    Dim swProfFeat              As SldWorks.feature

    Dim swProfSketch            As SldWorks.sketch

    

    Dim swPathFeat              As SldWorks.feature

    Dim swPathSketch            As SldWorks.sketch

    

    Dim vGuideCurvesTypeArr     As Variant

    Dim vGuideCurvesType        As Variant

    

    Dim bRet                    As Boolean

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swFeat = swSelMgr.GetSelectedObject5(1)

    Set swSweep = swFeat.GetDefinition

    

    ' Do not have to rollback to get sweep profile

    Set swProfFeat = swSweep.profile: Debug.Assert Not Nothing Is swProfFeat

    Set swProfSketch = swProfFeat.GetSpecificFeature: Debug.Assert Not Nothing Is swProfSketch

    ' Rollback now

    bRet = swSweep.AccessSelections(swModel, Nothing): Debug.Assert bRet

    

    Set swPathFeat = swSweep.path: Debug.Assert Not Nothing Is swPathFeat

    Set swPathSketch = swPathFeat.GetSpecificFeature: Debug.Assert Not Nothing Is swPathSketch

    

    vGuideCurvesTypeArr = swSweep.GetGuideCurvesType    'swSelectType_e

    ' TODO  swSweep.GuideCurves

    ' TODO  swSweep.StartDirectionVector

    ' TODO  swSweep.EndDirectionVector

    

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print "  " & swFeat.Name

    Debug.Print "    Path                   = " & swPathFeat.Name

    Debug.Print "    Profile                = " & swProfFeat.Name

    Debug.Print "    AdvancedSmoothing      = " & swSweep.AdvancedSmoothing

    Debug.Print "    AlignWithEndFaces      = " & swSweep.AlignWithEndFaces

    Debug.Print "    AutoSelect             = " & swSweep.AutoSelect

    Debug.Print "    EndTangencyType        = " & swSweep.EndTangencyType   'swTangencyType_e

    Debug.Print "    FeatureScope           = " & swSweep.FeatureScope

    Debug.Print "    FeatureScopeBodiesCnt  = " & swSweep.GetFeatureScopeBodiesCount

    

    If Not IsEmpty(vGuideCurvesTypeArr) Then

    Debug.Print "    Num GuideCurves        = " & UBound(vGuideCurvesTypeArr) + 1

        For Each vGuideCurvesType In vGuideCurvesTypeArr

    Debug.Print "      Type                 = " & vGuideCurvesType  'swSelectType_e

        Next vGuideCurvesType

    End If

    

    Debug.Print "    GetPathType            = " & swSweep.GetPathType       'swSelectType_e

    Debug.Print "    Wall thickness foward  = " & swSweep.GetWallThickness(True) * 1000# & " mm"

    Debug.Print "    Wall thickness reverse = " & swSweep.GetWallThickness(False) * 1000# & " mm"

    Debug.Print "    IsBossFeature          = " & swSweep.IsBossFeature

    Debug.Print "    IsThinFeature          = " & swSweep.IsThinFeature

    Debug.Print "    MaintainTangency       = " & swSweep.MaintainTangency

    Debug.Print "    Merge                  = " & swSweep.Merge

    Debug.Print "    MergeSmoothFaces       = " & swSweep.MergeSmoothFaces

    Debug.Print "    StartTangencyType      = " & swSweep.StartTangencyType 'swTangencyType_e

    Debug.Print "    TangentPropagation     = " & swSweep.TangentPropagation

    Debug.Print "    ThinWallType           = " & swSweep.ThinWallType

    Debug.Print "    TwistControlType       = " & swSweep.TwistControlType  'swTwistControlType_e

    ' Roll forward

    swSweep.ReleaseSelectionAccess

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:   Get Properties of Sweep Feature 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) 2015 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.