这样可以了
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 swSheetMetal As SldWorks.SheetMetalFeatureData
Dim bRet As Boolean
Dim boolstatus As Boolean
Dim swCustBend As SldWorks.CustomBendAllowance
Dim sswComponent As SldWorks.Component
Dim Value As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
boolstatus = swModel.Extension.SelectByID2("钣金", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
Set swFeat = swSelMgr.GetSelectedObject5(1)
Set swSheetMetal = swFeat.GetDefinition
Value = swSheetMetal.SetUseGaugeTable(False, "")
Set swCustBend = swSheetMetal.GetCustomBendAllowance
If Not swCustBend.Type = swBendAllowanceKFactor Then
swCustBend.Type = swBendAllowanceKFactor
Call swSheetMetal.SetCustomBendAllowance(swCustBend)
End If
boolstatus = swFeat.ModifyDefinition(swSheetMetal, swModel, sswComponent)
End Sub
|