I've written a macro which does several updates to parts, including ensuring that the latest gauge tables are assigned and control the bend dimensions. However, several parts are resulting with errors in Closed Corners or Flat Patterns. It seems to be a result of the gauge tables not processing fully, because if I edit the multibody Sheet-Metal folder or the Sheet-Metal body feature within it and only hit confirm, I see the Excel gauge table appear briefly, the part regenerates, and then the errors disappear.
sGaugeTblFile = sGaugeTblDir & sPS & sPrefix & sSuffix
' Set multibody sheet metal folder to use gauge table
Set swFeat = swModelExt.GetTemplateSheetMetal
If Not swFeat Is Nothing Then
Set swSMData = swFeat.GetDefinition
swSMData.AccessSelections swModel, Nothing
swSMData.SetUseGaugeTable False, ""
swSMData.SetUseGaugeTable True, sGaugeTblFile
Set swCustBend = swSMData.GetCustomBendAllowance
swCustBend.Type = swBendAllowanceGaugeTable
Call swSMData.SetCustomBendAllowance(swCustBend)
bOpSuccess = bOpSuccess * swFeat.ModifyDefinition(swSMData, _
swModel, _
Nothing)
End If
' Set individual sheet metal bodies to use gauge table
Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
Select Case swFeat.GetTypeName2
Case "SheetMetal"
Set swSMData = swFeat.GetDefinition
swSMData.AccessSelections swModel, Nothing
' Activate use of Gauge Table
lGaugeTblRet = swSMData.GetUseGaugeTable(bUseGaugeTbl, sOldGaugeTbl)
If Not bUseGaugeTbl Then
' Activate Gauge Table
swSMData.SetUseGaugeTable True, ""
End If
' Ensure override states
iErrOut = swSMData.SetOverrideDefaultParameter2(swSheetMetalOverrideDefaultParameters_BendParameters, False)
iErrOut = swSMData.SetOverrideDefaultParameter2(swSheetMetalOverrideDefaultParameters_BendAllowance, True)
iErrOut = swSMData.SetOverrideDefaultParameter2(swSheetMetalOverrideDefaultParameters_AutoRelief, False)
' Switch to use Gauge Table for Bend Allowance
Set swCustBend = swSMData.GetCustomBendAllowance
If swCustBend.Type <> swBendAllowanceGaugeTable Then
swCustBend.Type = swBendAllowanceGaugeTable
Call swSMData.SetCustomBendAllowance(swCustBend)
End If
bOpSuccess = bOpSuccess * swFeat.ModifyDefinition(swSMData, _
swModel, _
Nothing)
Case "SMBaseFlange"
Set swBFData = swFeat.GetDefinition
swBFData.AccessSelections swModel, Nothing
' Activate use of Gauge Table
bUseGaugeTbl = swBFData.UseGaugeTable
If Not bUseGaugeTbl Then
' Activate Gauge Table
swBFData.UseGaugeTable = True
End If
' Ensure overrides are off
With swBFData
.OverrideDefaultSheetMetalParameters = False
.OverrideThickness = False
.OverrideRadius = False
End With ' swBFData
bOpSuccess = bOpSuccess * swFeat.ModifyDefinition(swBFData, _
swModel, _
Nothing)
Case "SolidToSheetMetal"
' Unknown if anything is needed here
End Select
Set swFeat = swFeat.GetNextFeature
Loop
' Setup Thickness
' Note: This does not need to be condition-limited.
' Thickness will simply remap to the same value.
Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
Select Case swFeat.GetTypeName2
Case "SheetMetal"
' Placeholder for figuring out how to set gauge at parent level
Case "SMBaseFlange"
' This will work for most parts
Set swBFData = swFeat.GetDefinition
With swBFData
vThicknesses = .GetTableThicknesses
.ThicknessTableName = vThicknesses(iGauge)
vRadii = .GetTableRadii(vThicknesses(iGauge)) ' Note: In METERS
.TableRadius = vRadii(0) / 0.0254
' Seems our gauge tables only produce one radius
End With
bOpSuccess = bOpSuccess * swFeat.ModifyDefinition(swBFData, _
swModel, _
Nothing)
Case "SolidToSheetMetal"
' Some parts are created as extrusions and then converted and need special handling
bOpSuccess = False
Set swCSFData = swFeat.GetDefinition
End Select
Set swFeat = swFeat.GetNextFeature
Loop