Hide Table of Contents

Modify Fillet Weld Bead Example (VBA)

This example shows how to modify a fillet weld bead.

 

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

'

' Preconditions: Model document is open and

'                model contains FilletBead1 feature.

'

' Postconditions: FilletBead1 feature modified (change faces,

'                (virtual edges, and properties)

'

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

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 swComp As SldWorks.Component

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 tp 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 FilletBead1 feature

boolstatus = swModelDocExt.SelectByID2("Fillet Bead1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

Set swFeat = swSelMgr.GetSelectedObject5(1)

Set swWeldBead = swFeat.GetDefinition

 

'Roll back to the feature just above FilletBead1

boolstatus = swWeldBead.AccessSelections(swModel, Nothing)

 

'Get FilletBead1 properties

bdlen = swWeldBead.BeadLength(swWeldBeadArrowSide)

bdPitch = swWeldBead.BeadPitch(swWeldBeadArrowSide)

bdsz = swWeldBead.BeadSize(swWeldBeadArrowSide)

bdTy = swWeldBead.BeadType(swWeldBeadArrowSide)

tp = swWeldBead.TangentPropagation

 

'Get FilletBead1 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 FilletBead1 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

 

Stop 'Select new faces

 

Set f1(0) = swSelMgr.GetSelectedObject5(1)

Set f2(0) = swSelMgr.GetSelectedObject5(2)

Set f2(1) = swSelMgr.GetSelectedObject5(3)

fVar1 = f1

fVar2 = f2

'Set new faces

boolstatus = swWeldBead.SetFaces(swWeldBeadArrowSide, (fVar1), (fVar2))

 

'Get virtual edges

ve = swWeldBead.GetVirtualEdges(False, swWeldBeadArrowSide)

boolstatus = ve(0).Select4(True, swSelData)

 

'Set only first virtual edge

Set e(0) = ve(0)

ve = e

swWeldBead.SetVirtualEdges swWeldBeadArrowSide, (ve)

 

'Set new properties

swWeldBead.BeadLength(swWeldBeadArrowSide) = bdlen * 1.5

swWeldBead.BeadPitch(swWeldBeadArrowSide) = bdPitch * 1.5

swWeldBead.BeadSize(swWeldBeadArrowSide) = bdsz * 1.5

swWeldBead.BeadType(swWeldBeadArrowSide) = bdTy

If tp = False Then tp = True Else tp = False

swWeldBead.TangentPropagation = tp

 

'Modify FilletBead1 feature

boolstatus = swFeat.ModifyDefinition(swWeldBead, swModel, swComp)

 

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) 2014 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.