Set Custom Bend Deduction (VBA)
This example shows how to set the custom bend deduction for the selected
bend feature.
'------------------------------------------------------------------
'
' Preconditions:
' (1)
Sheet metal part is open.
' (2)
Bend feature is selected.
'
' Postconditions: Selected bend feature is modified.
'
'------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long
Dim FeatureData As SldWorks.SketchBendFeatureData
Dim Feature As SldWorks.Feature
Dim Component As SldWorks.Component
Dim nam As String
Sub main()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
' Get the selected bend feature
Set Feature = Part.SelectionManager.GetSelectedObject5(1)
'Get the name of the selected bend feature
nam = Feature.GetTypeName
Set FeatureData = Feature.GetDefinition
' Get whether to use default bend allowance to determine
the current state
' NEEDED?
Dim useCustom As Boolean
useCustom = FeatureData.UseDefaultBendAllowance
' Get the custom bend allowance object
Dim bData As SldWorks.CustomBendAllowance
Set bData = FeatureData.GetCustomBendAllowance
Dim bType As Long
bType = bData.Type
' Set the bend allowance type to bend deduction
bData.Type = swBendAllowanceDeduction
' Set the value of the bend deduction
bData.BendDeduction
= 0.001
FeatureData.UseDefaultBendAllowance
= False
'Set the value of the bend deduction
Call FeatureData.SetCustomBendAllowance(bData)
' Modify the bend
boolstatus = Feature.ModifyDefinition(FeatureData,
Part, Component)
End Sub