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
'--------------------------------------