Get Properties of Sweep Feature Example (VBA)
This example shows how to get the properties of a sweep feature.
'------------------------------------------------------
' Preconditions:
' 1. Open public_documents\tutorial\api\cstick.sldprt.
' 2. Select Sweep1.
'
' Postconditions: Examine the Immediate area.
'
' NOTE: Because the part is used elsewhere, do not
' save changes.
'------------------------------------------------------
Option Explicit
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
Set swProfSketch = swProfFeat.GetSpecificFeature
' Rollback now
bRet = swSweep.AccessSelections(swModel, Nothing)
Set swPathFeat = swSweep.Path
Set swPathSketch = swPathFeat.GetSpecificFeature
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