Hide Table of Contents

Change Bend Radius of Sketched Bend Example (VBA)

This example shows how to change the bend radius of a sketched bend.

 

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

'

' Preconditions:

'      (1) Model document is open.

'      (2) Sketched bend is selected.

'

' Postconditions: Size of bend radius of the selected sketched bend

'       is increased by 1.5 times.

'

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

Option Explicit

Public Enum swFlangePositionTypes_e

    swFlangePositionTypeMaterialInside = 1

    swFlangePositionTypeMaterialOutside = 2

    swFlangePositionTypeBendOutside = 3

    swFlangePositionTypeBendCenterLine = 4

    swFlangePositionTypeBendSharp = 5

End Enum

Public Enum swBendAllowanceTypes_e

    swBendAllowanceBendTable = 1

    swBendAllowanceKFactor = 2

    swBendAllowanceDirect = 3

    swBendAllowanceDeduction = 4

End Enum

Sub DumpCustomBendAllowanceInfo _

( _

    sPadStr As String, _

    swCustBendAllow As SldWorks.CustomBendAllowance _

)

    Debug.Print sPadStr & "Type                     = " & swCustBendAllow.Type

    Debug.Print sPadStr & "BendAllowance            = " & swCustBendAllow.BendAllowance * 1000# & " mm"

    Debug.Print sPadStr & "BendDeduction            = " & swCustBendAllow.BendDeduction * 1000# & " mm"

    Debug.Print sPadStr & "BendTableFile            = " & swCustBendAllow.BendTableFile

    Debug.Print sPadStr & "KFactor                  = " & swCustBendAllow.KFactor

End Sub

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swSelData               As SldWorks.SelectData

    Dim swFeat                  As SldWorks.feature

    Dim swSketchBend            As SldWorks.SketchedBendFeatureData

    Dim swBendFeat              As SldWorks.BendsFeatureData

    Dim swCustBendAllow         As SldWorks.CustomBendAllowance

    Dim swFace                  As SldWorks.face2

    Dim swEnt                   As SldWorks.Entity

    Dim nFace_X                 As Double

    Dim nFace_Y                 As Double

    Dim nFace_Z                 As Double

    Dim i                       As Long

    Dim bRet                    As Boolean

    

    Set swApp = CreateObject("SldWorks.Application")

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swSelData = swSelMgr.CreateSelectData

    Set swFeat = swSelMgr.GetSelectedObject5(1)

    Set swSketchBend = swFeat.GetDefinition

    Set swCustBendAllow = swSketchBend.GetCustomBendAllowance

    

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print "  " & swFeat.Name

    Debug.Print "    BendAngle                  = " & swSketchBend.BendAngle * 57.3 & " deg"

    Debug.Print "    BendRadius                 = " & swSketchBend.BendRadius * 1000# & " mm"

    Debug.Print "    PositionType               = " & swSketchBend.PositionType

    Debug.Print "    ReverseDirection           = " & swSketchBend.ReverseDirection

    Debug.Print "    UseDefaultBendAllowance    = " & swSketchBend.UseDefaultBendAllowance

    Debug.Print "    UseDefaultBendRadius       = " & swSketchBend.UseDefaultBendRadius

    ' Roll back to get to fixed face

    bRet = swSketchBend.AccessSelections(swModel, Nothing): Debug.Assert bRet

    

    Set swFace = swSketchBend.GetFixedFace(nFace_X, nFace_Y, nFace_Z)

    Set swEnt = swFace

    

    Debug.Print "    Fixed Face                 = (" & nFace_X * 1000# & ", " & nFace_Y * 1000# & ", " & nFace_Z * 1000# & ") mm"

    

    Debug.Print "    Custom Bend Allowance:"

    DumpCustomBendAllowanceInfo "      ", swCustBendAllow

    

    bRet = swEnt.Select4(True, swSelData): Debug.Assert bRet

    

    ' Make some changes

    swSketchBend.UseDefaultBendRadius = False

    swSketchBend.BendRadius = swSketchBend.BendRadius * 1.5

    

    ' Apply changes

    bRet = swFeat.ModifyDefinition(swSketchBend, swModel, Nothing): Debug.Assert bRet

    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:   Change Bend Radius of Sketched Bend 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) 2013 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.