Modify Closed Corner Feature Example (VBA)
This example shows how to modify a closed corner feature in a sheet
metal part.
'-------------------------------------
'
' Preconditions: Sheet metal part open that
' has
a Closed Corner feature
'
' Postconditions: Closed corner feature modified
' as
specified in macro.
'
'-------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim component As SldWorks.Component2
Dim Feature As Object
Sub main()
Set
swApp = Application.SldWorks
Set
swDoc = swApp.ActiveDoc
Set
SelMgr = swDoc.SelectionManager
Dim
swFeat As SldWorks.Feature
Dim
swFeatData As SldWorks.ClosedCornerFeatureData
Dim
bRet As Boolean
'
Traverse the FeatureManager design tree
'
When CornerFeat found, modify it
Set
swFeat = swDoc.FirstFeature
Do
While Not swFeat Is Nothing
Debug.Print
swFeat.GetTypeName
If
swFeat.GetTypeName = "CornerFeat" Then
Set
swFeatData = swFeat.GetDefinition
bRet
= swFeatData.AccessSelections(swDoc,
component)
Debug.Print
"AccessSelections:", bRet
Debug.Print
"-------------Before--------------"
Debug.Print
"CornerType:", swFeatData.CornerType
Debug.Print
"GapDistance:", swFeatData.GapDistance
Debug.Print
"OverlapUnderlapRatio:", swFeatData.OverlapUnderlapRatio
Debug.Print
"OpenBendRegion:", swFeatData.OpenBendRegion
swFeatData.GapDistance
= 0.0002
swFeatData.OverlapUnderlapRatio
= 0.5
swFeatData.OpenBendRegion
= True
Debug.Print
"-------------After--------------"
Debug.Print
"GapDistance:", swFeatData.GapDistance
Debug.Print
"OverlapUnderlapRatio:", swFeatData.OverlapUnderlapRatio
Debug.Print
"OpenBendRegion:", swFeatData.OpenBendRegion
bRet
= swFeat.ModifyDefinition(swFeatData,
swDoc, Nothing)
Debug.Print
"ModifyDefinition:", bRet
swFeatData.ReleaseSelectionAccess
End
If
Set
swFeat = swFeat.GetNextFeature
Loop
End Sub