I have been trying to get the k factor used by a sheet metal feature that utilizes a gauge table. It looks like solidworks provides a few different ways to do this but none of them seem to work. I think the root of the problem is that solidworks is not applying the k factor in my gauge table to the sheet metal feature, instead falling back on the default. Anyone have any ideas what's going on?
Here's what my gauge table looks like: (target bend and k-factor circled in red)
Here's my code (runs after a rebuild)
Function PartDoc_onIdleNotify() As Integer
Dim swConfigMgr As ConfigurationManager
Dim swConfig As Configuration
Dim OrigConfig As String
Dim v As Object
Dim i As Integer
Dim flatPatternFeature As IFeature = Nothing
Dim swFeatMgr As IFeatureManager
Dim swFeat As IFeature
Dim gageTablePath As String
Dim BaseFlangeFeat As IBaseFlangeFeatureData
Dim swSheetMetal As SheetMetalFeatureData
Dim custBendAll As CustomBendAllowance
Dim thickness As String
Dim myDimension As Object
If onIdleFlag = False Then
onIdleFlag = True
RemoveHandler iSwApp.OnIdleNotify, AddressOf PartDoc_onIdleNotify
Exit Function
End If
flatPatternFeature = iPart.FeatureByName("Flat-Pattern1")
If flatPatternFeature IsNot Nothing Then
'get the base flange feature
swFeat = iPart.FeatureByName("Base-Flange1")
If swFeat IsNot Nothing Then
'get all the data for the base flange feature
BaseFlangeFeat = swFeat.GetDefinition
gageTablePath = BaseFlangeFeat.GaugeTablePath
thickness = BaseFlangeFeat.ThicknessTableName
thickness = Replace(thickness, "Gauge ", "", )
thickness = Left(thickness, 2)
thickness = Trim(thickness)
'write out the gage number
myDimension = iPart.Parameter("GaugeNumber@Sketch1")
myDimension.systemvalue = Convert.ToDouble(thickness) / 1000
swFeat = Nothing
End If
swFeat = iPart.FeatureByName("Sheet-Metal1")
If swFeat IsNot Nothing Then
swSheetMetal = swFeat.GetDefinition
myDimension = iPart.Parameter("kfactor@Sketch1")
custBendAll = swSheetMetal.GetCustomBendAllowance
'myDimension.SystemValue = custBendAll.KFactor / 1000
End If
'collect the config names, loop through them and unsuppress/suppress the flat pattern
swConfigMgr = iPart.ConfigurationManager
swFeatMgr = iPart.FeatureManager
OrigConfig = swConfigMgr.ActiveConfiguration.Name
v = iPart.GetConfigurationNames
rebuildFlag = False
For i = 0 To UBound(v)
swConfig = iPart.GetConfigurationByName(v(i))
If flatPatternFeature.IsSuppressed() Then
flatPatternFeature.SetSuppression(2)
flatPatternFeature.SetSuppression(0)
End If
Next
'iPart.ShowConfiguration2(OrigConfig)
iPart.ForceRebuild()
rebuildFlag = True
End If
end function
When I do a watch on swSheetMetal I get this:
Any thoughts?
SolidworksApi macros