I am finding that parts created with Solidworks 2013 or Solidworks 2014 seem to not update their BendAllowanceType when it is changed in code. The BendAllowanceType can be changed in the Sheet-Metal feature by selecting either Bend Table, K-Factor, Bend Allowance, etc in the drop down menu in the Edit Feature pane. The BendAllowanceType changes when changed in code for parts created in older versions of Solidworks.
The difference I see between previous parts and parts created with Solidworks>2012 is that there is an additional child Sheet-Metal item under the Sheet-Metal feature in the feature tree.
Here is my code that changes the BendAllowanceType in older versions of Solidworks, but not in newer versions.
Dim swModel As ModelDoc2 = Iswapp.IActiveDoc
swModel.DeleteBendTable() 'Delete old bend table so the new one is loaded from the xls file - this changes the BendAllowanceType back to k-factor which is not what we want
model = swModel
Dim bendTable As String = "C:\BendTable.xls"
Dim smFeatData As SheetMetalFeatureData
Dim featName As String
Dim swCustBendAllow As CustomBendAllowance
For Each swFeat As Feature In model.FeatureManager.GetFeatures(True)
featName = swFeat.GetTypeName()
If featName = "SheetMetal" Then
'Insert bend table - do not want k-factor
smFeatData = swFeat.GetDefinition
'trying this out to see if it works. Doesn't work with new parts but works with old parts
swCustBendAllow = smFeatData.GetCustomBendAllowance
swCustBendAllow.Type = swBendAllowanceTypes_e.swBendAllowanceBendTable ' changes the Type to a 1 which looks correct but the Sheet-Metal feature does not change in the bend allowance section
swFeat.ModifyDefinition(smFeatData, swModel, Nothing)
'Old method which only works with parts created with sw<2013 where the sheetmetal feature does not have a subfeature
smFeatData.BendAllowanceType = swBendAllowanceTypes_e.swBendAllowanceBendTable
smFeatData.BendTableFile = bendTable
swFeat.IModifyDefinition2(smFeatData, model, Nothing)
I have been struggling with this for over a year and figured it would be fixed in Solidworks 2014 but it has not been.
Thank you, Luke
Here is the bend allowance asetting that goes back to k-factor when the above code is run for a part created in sw2013 or sw2014.
Here's the feature tree for a part created in sw2012. Notice that there is no sheet-metal feature under the sheet-metal feature.
Here's the feature tree for a part created in sw2014. Notice that there is a sheet-metal feature under the sheet-metal feature. I'm not sure if this is what is causing the issue, but it's the only difference I see. I tried going to the firstchild after getting to the sheetmetal feature but it returned Nothing.