Modify Break Corner Feature Example (VBA)
This example shows how to modify a break corner feature in a sheet metal
part.
'------------------------------------
'
' Preconditions: Sheet metal part is open and
' has
a break corner/corner trim feature.
'
' Postconditions: Apply changes to internal corners only
and center the
' corner
trims relative to the bend lines.
'
'------------------------------------
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.BreakCornerFeatureData
Dim
bRet As Boolean
'
Iterate the features until CornerTrim feature found
Set
swFeat = swDoc.FirstFeature
Do
While Not swFeat Is Nothing
Debug.Print
swFeat.GetTypeName
'
If corner trim feature, then add corner trims centered
'
relative to the bend lines and apply to internal corners only
If
swFeat.GetTypeName = "CornerTrim" Then
Set
swFeatData = swFeat.GetDefinition
bRet
= swFeatData.AccessSelections(swDoc,
component)
Debug.Print
"AccessSelections:", bRet
Debug.Print
"-------------Before--------------"
Debug.Print
"CenteredOnBendLines:", swFeatData.CenteredOnBendLines
Debug.Print
"InternalCornersOnly:", swFeatData.InternalCornersOnly
swFeatData.InternalCornersOnly
= True
swFeatData.CenteredOnBendLines
= True
Debug.Print
"-------------After--------------"
Debug.Print
"CenteredOnBendLines:", swFeatData.CenteredOnBendLines
Debug.Print
"InternalCornersOnly:", swFeatData.InternalCornersOnly
bRet
= swFeat.ModifyDefinition(swFeatData,
swDoc, Nothing)
Debug.Print
"ModifyDefinition:", bRet
swFeatData.ReleaseSelectionAccess
End
If
Set
swFeat = swFeat.GetNextFeature
Loop
End Sub