Hide Table of Contents

Create Base-Flange Feature Using Gauge Table Example (VBA)

This examples shows how to create a base-flange feature using a gauge table.

 

'------------------------------------------------

'

' Preconditions: Part document containing a

'                Sketch1 feature is open.

'

' Postconditions: Base-Flange feature created.

'

'-------------------------------------------------

Option Explicit

Sub main()

    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2

    Dim swFeatMgr As SldWorks.FeatureManager

    Dim swModelDocExt As SldWorks.ModelDocExtension

    Dim SelMgr As SldWorks.SelectionMgr

    Dim pFeatDef As SldWorks.BaseFlangeFeatureData

    Dim boolstatus As Boolean

    Dim pFeat As Object

    Dim i As Long

    Dim j As Long

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swFeatMgr = swModel.FeatureManager

    Set swModelDocExt = swModel.Extension

    Set SelMgr = swModel.SelectionManager

    swModel.ClearSelection2 True

    

    Set pFeatDef = swFeatMgr.CreateDefinition(swFmBaseFlange)

    

    pFeatDef.BendRadius = 0.02

    pFeatDef.D1OffsetDistance = 0.04

    pFeatDef.D1OffsetType = 1

    pFeatDef.D1ReverseOffset = True

    pFeatDef.D2OffsetDistance = 0.001

    pFeatDef.D2OffsetType = 1

    pFeatDef.D2ReverseOffset = True

    pFeatDef.OffsetDirections = 1

    pFeatDef.ReverseDirection = False

    pFeatDef.ReverseThickness = False

    

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

    ' you must set these values in sequence

    pFeatDef.UseGaugeTable = True

    ' Set the path to where the sheet metal gauge tables are stored on disk

    pFeatDef.GaugeTablePath = "c:\Program Files\SolidWorks\SolidWorks\lang\english\Sheet Metal Gauge Tables\sample table - steel - english units.xls"

    Dim ThicknessNames As Variant

    Dim Radii As Variant

    ThicknessNames = pFeatDef.GetTableThicknesses()

    

    If (IsEmpty(ThicknessNames)) Then

        MsgBox "Invalid gauge table path."

        End

    End If

    

    Debug.Print " Table Thickness Names"

    For i = 0 To UBound(ThicknessNames)

        Debug.Print ThicknessNames(i)

        Radii = pFeatDef.GetTableRadii(ThicknessNames(i))

        For j = 0 To UBound(Radii)

            Debug.Print Radii(j)

        Next

        

    Next i

    

    ' Use the values from the previous API to set the following values

    pFeatDef.ThicknessTableName = ThicknessNames(3)

    Debug.Print " Thickness Value" & ThicknessNames(0) & " = " & pFeatDef.TableThickness

    ' Get updated radii for new table, which was set previously

    Radii = pFeatDef.GetTableRadii(ThicknessNames(3))

    pFeatDef.TableRadius = Radii(3)

   

   

    Dim Override As Boolean

    Stop

    ' Set value to what user wants

    Override = False

    If (Override = True) Then

        pFeatDef.OverrideRadius = True

        pFeatDef.OverrideThickness = True

        pFeatDef.OverrideKFactor = True

    Else

        pFeatDef.OverrideRadius = False

        pFeatDef.OverrideThickness = False

        pFeatDef.OverrideKFactor = False

    End If

        

    ' If above Override value is true, then use following API to set Override value

    If (Override = True) Then

        pFeatDef.Thickness = "0.06"

        pFeatDef.BendRadius = 0.012

        pFeatDef.KFactor = 0.75

    End If

       

    

    swModel.ShowNamedView2 "*Trimetric", 8

    boolstatus = swModelDocExt.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)

    

    ' Create the feature

    Set pFeat = swFeatMgr.CreateFeature(pFeatDef)

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Base-Flange Feature Using Gauge Table Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2011 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.