Hide Table of Contents

Insert Weld Bead Example (VBA)

This example shows how to create a weld bead by programmatically selecting the top, stop, and contact faces and passing those faces as arrays to  IAssemblyDoc::InsertWeld2.

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

' Preconditions: Open an assembly document

'                in which you want to insert a

'                weld bead.

'

' Postconditions: Weld bead created using the

'                specified top, stop, and contact

'                faces. Weld bead appears in the

'                FeatureManager design tree as a

'                feature and now exists as a SolidWorks

'                part document in c:\temp\bead2.sldprt.

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

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swSelectionMgr As SldWorks.SelectionMgr

Dim topFaces(1) As Object

Dim t As Variant

Dim stopFaces(3) As Object

Dim s As Variant

Dim contactFaces(3) As Object

Dim c As Variant

Dim swAssembly As SldWorks.AssemblyDoc

Dim boolstatus As Boolean

 

Sub main()

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension

Set swSelectionMgr = swModel.SelectionManager

 

' Select top faces for the weld bead

' Substitute your selections for the weld bead's top faces

boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.01559163546833, 0.02520890274226, 0.02853818512551, True, 0, Nothing, 0)

Set topFaces(0) = swSelectionMgr.GetSelectedObject6(1, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01969239735822, 0.03064046036471, 0.01000498670771, True, 0, Nothing, 0)

Set topFaces(1) = swSelectionMgr.GetSelectedObject6(2, -1)

t = topFaces

swModel.ClearSelection2 True

 

' Select stop faces for the weld bead

' Substitute your selections for the weld bead's stop faces

boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.01445017029672, 0.01448327651559, 0.07619999999997, True, 0, Nothing, 0)

Set stopFaces(0) = swSelectionMgr.GetSelectedObject6(1, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01773464730298, 0.01977465429431, 0.0432803149497, True, 0, Nothing, 0)

Set stopFaces(1) = swSelectionMgr.GetSelectedObject6(2, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.0195767596401, 0.02039971255846, -0.03291968505005, True, 4, Nothing, 0)

Set stopFaces(2) = swSelectionMgr.GetSelectedObject6(3, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.0218293117176, 0.01005028977147, 0, True, 4, Nothing, 0)

Set stopFaces(3) = swSelectionMgr.GetSelectedObject6(4, -1)

s = stopFaces

swModel.ClearSelection2 True

 

' Select contact faces for the weld bead

' Substitute your selections for the weld bead's contact faces

boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.00139666394648, 0.0163969139561, 0.05736881478452, True, 2, Nothing, 0)

Set contactFaces(0) = swSelectionMgr.GetSelectedObject6(1, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0, 0.009181832977731, 0.05743695965685, True, 2, Nothing, 0)

Set contactFaces(1) = swSelectionMgr.GetSelectedObject6(2, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.01087386157639, 0.009644726364513, -0.02560526716087, True, 2, Nothing, 0)

Set contactFaces(2) = swSelectionMgr.GetSelectedObject6(3, -1)

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.006349999999941, 0.02091223363979, -0.01486524507766, True, 2, Nothing, 0)

Set contactFaces(3) = swSelectionMgr.GetSelectedObject6(4, -1)

c = contactFaces

swModel.ClearSelection2 True

 

' Insert a weld bead

Set swAssembly = swModel

swAssembly.InsertWeld2 "BACK", "CNV", 0.009525, 0.009525, 0.0381, "C:\temp\bead2.sldprt", t, s, c

 

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:   Insert 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) 2010 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.