AnsweredAssumed Answered

Midplane Sheet Metal macro Feature Definition Help

Question asked by Matt B. on Oct 3, 2017
Latest reply on Oct 10, 2017 by Matt B.

So I have written a macro that succesfully creates a MidPlane sheetmetal base flange - it creates an offset plane, moves a sketch to that plane, creates a sheetmetal flange, and then adds equations to make the plane offset be the half-width of the sheetmetal.

 

My problem is that my code currently makes all of the sheet metal features use the newly selected thickness, instead of just the new feature. (I.E. I want this new flange to be it's own thickness from a table, selectable by user. But this new selection gets applied globally, instead of just locally)

 

Also, critically, SolidWorks doesn't create a "D7@Sheet-Metal#" custom thickness dimension to use in the above equations.

 

Does anybody have any idea why these two things happen? Here's the operative code:

 

-------------------

Dim featDef As SldWorks.BaseFlangeFeatureData

Set featDef = swFeatmgr.CreateDefinition(swFmBaseFlange)

 

' need to ask user for thickness preference

nStatus = swSMFeatData.GetUseGaugeTable(bRet, sTableFile)

 

featDef.BendRadius = swSMFeatData.BendRadius

featDef.D1OffsetDistance = 0#

featDef.D1OffsetType = 0

featDef.D1ReverseOffset = False

featDef.D2OffsetDistance = 0#

featDef.D2OffsetType = 0

featDef.D2ReverseOffset = False

featDef.OffsetDirections = 0

featDef.ReverseDirection = False ' This line seems to control closed-profile base flange thickness direction.

featDef.ReverseThickness = False

 

'All of the following values depend on the previous values;

' you must set these values in sequence

featDef.UseGaugeTable = True

 

' Set the path to the sheet metal gauge tables

featDef.GaugeTablePath = sTableFile

 

ThicknessNames = featDef.GetTableThicknesses()

 

If (IsEmpty(ThicknessNames)) Then

    MsgBox "ERROR: No sheetmetal table. At this time,this sheet metal body cannot be the first one in the model."

    'TODO: Load thickness table seperately, use userform input to create sheetmetal

   

    End

Else

 

    gThicknessNames = ThicknessNames

 

   ' get user input

    UserForm1.Show

   

End If

  

' Set override values

If gUseDefault Then

    override = False

Else

    override = True

End If

 

 

If (override = True) Then

    featDef.OverrideRadius = False

    featDef.OverrideThickness = True 'False ' hoping this lets the system choose table radius and kfactor

    featDef.OverrideKFactor = False

   

    featDef.ThicknessTableName = gUserThickness

   

Else

    featDef.OverrideRadius = False

    featDef.OverrideThickness = False

    featDef.OverrideKFactor = False

End If

 

Set swNewFeat = swFeatmgr.CreateFeature(featDef)

Outcomes