Hide Table of Contents

Modify Fillet Weld Bead Example (VBA)

This example shows how to modify a fillet weld bead.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open install_dir\samples\tutorial\api\weldment_box3.sldprt.
' 2. Open an Immediate window.
'
' Postconditions:
' 1. Inspect the Immediate window to see the properties of Fillet Bead1.
' 2. Modifies some properties of Fillet Bead1.
'
' NOTE: Because the model is used elsewhere, do not save changes.
'---------------------------------------------------------------------------

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swWeldBead As SldWorks.WeldmentBeadFeatureData
Dim swFeat As SldWorks.Feature
Dim swSelData As SldWorks.SelectData
Dim v1 As SldWorks.Vertex
Dim v2 As SldWorks.Vertex
Dim set1 As Variant
Dim faceVar As Variant
Dim ve As Variant
Dim fVar1 As Variant
Dim fVar2 As Variant
Dim f1(0) As Object
Dim f2(1) As Object
Dim e(0) As Object
Dim bdlen As Double
Dim bdPitch As Double
Dim bdsz As Double
Dim bdTy As Long
Dim i As Long
Dim boolstatus As Boolean
 

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swModelDocExt = swModel.Extension
    Set swSelMgr = swModel.SelectionManager
    Set swSelData = swSelMgr.CreateSelectData
    

    'Select Fillet Bead1 feature
    boolstatus = swModelDocExt.SelectByID2("Fillet Bead1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
    Set swFeat = swSelMgr.GetSelectedObject6(1, -1)
    Set swWeldBead = swFeat.GetDefinition
   

    'Roll back to the feature just before Fillet Bead1
    boolstatus = swWeldBead.AccessSelections(swModel, Nothing)
   

    'Get Fillet Bead1 properties
    Debug.Print "Fillet Bead1 properties:"
    bdlen = swWeldBead.BeadLength(swWeldBeadArrowSide)
    Debug.Print "  Weld bead length: " & bdlen
   

    bdPitch = swWeldBead.BeadPitch(swWeldBeadArrowSide)
    Debug.Print "  Weld bead pitch: " & bdPitch
   

    bdsz = swWeldBead.BeadSize(swWeldBeadArrowSide)
    Debug.Print "  Weld bead size: " & bdsz
   

    bdTy = swWeldBead.BeadType(swWeldBeadArrowSide)
    Debug.Print "  Weld bead type as defined in swWeldBeadType_e: " & bdTy
   

    Debug.Print "  Propagate the weld bead along the tangent? " & swWeldBead.TangentPropagation
    Debug.Print "  Apply weld bead to both sides of intersecting faces? " & swWeldBead.UseOtherSide
   

    'Get Fillet Bead1 faces
    swWeldBead.GetFaces swWeldBeadArrowSide, set1, faceVar
   

    For i = LBound(faceVar) To UBound(faceVar)
        faceVar(i).Select4 True, swSelData
    Next i
   

    For i = LBound(set1) To UBound(set1)
        set1(i).Select4 True, swSelData
    Next i
   

    'Get Fillet Bead1 virtual edges
    ve = swWeldBead.GetVirtualEdges(False, swWeldBeadArrowSide)
   

    For i = LBound(ve) To UBound(ve)
        boolstatus = ve(i).Select4(True, swSelData)
        Set v1 = ve(i).GetStartVertex
        Set v2 = ve(i).GetEndVertex
    Next i
   

    swModel.ClearSelection2 True
   

    'Set new properties of Fillet Bead1
    swWeldBead.BeadLength(swWeldBeadArrowSide) = bdlen * 0.5
    swWeldBead.BeadPitch(swWeldBeadArrowSide) = bdPitch * 0.5
    swWeldBead.BeadSize(swWeldBeadArrowSide) = bdsz * 0.5
    swWeldBead.BeadType(swWeldBeadArrowSide) = bdTy
   

    'Modify Fillet Bead1
    boolstatus = swFeat.ModifyDefinition(swWeldBead, swModel, Nothing)
   

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:   Modify Fillet Weld Bead 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) 2015 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.