Hide Table of Contents

Insert Cosmetic Weld Bead Example (VB.NET)

This example shows how to insert a cosmetic weld bead feature and access its properties.

' Preconditions: Open:
'    install_dir\samples\tutorial\api\Insert_weld.sldprt
' Postconditions:
' 1. A fillet weld, Weld Bead2, is created and added to the Weld Folder in
'    the FeatureManager design tree.
' 2. Inspect the Weld Bead1 settings and properties in the Immediate window.
' NOTE: Because the model is used elsewhere,
' do not save changes when closing it.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.Sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

Dim Part As ModelDoc2
Dim boolstatus As Boolean
    Dim FeatureData As CosmeticWeldBeadFeatureData
Dim WeldFolder As CosmeticWeldBeadFolder
Dim selman As SelectionMgr
Dim myFeature As Feature

Sub main()

        Part = swApp.ActiveDoc
        boolstatus = Part.Extension.SelectByID2(
"", "FACE", -0.0344320907599354, 0.0170180000000641, -0.00227566098720899, False, 0, Nothing, 0)
        boolstatus = Part.Extension.SelectByID2(
"", "FACE", -0.0161637176506133, 0.0503122973344716, -0.0013752238241409, True, 0, Nothing, 0)

        myFeature = Part.FeatureManager.InsertCosmeticWeldBead(0.51)

        boolstatus = Part.Extension.SelectByID2(
"Weld Bead1", "COSMETIC_WELD", 0, 0, 0, False, 0, Nothing, 0)

        selman = Part.SelectionManager
        myFeature = selman.GetSelectedObject6(1, 0)
        FeatureData = myFeature.GetDefinition

"weld bead settings: ")
"   weld bead size was " & FeatureData.BeadSize)
        FeatureData.BeadSize = 0.6
"   weld bead size is now " & FeatureData.BeadSize)
If FeatureData.TangentPropagation = False Then
            FeatureData.TangentPropagation = True
        End If
        Debug.Print("   tangent propagation? " & FeatureData.TangentPropagation)
"   weld sides as defined in swCosmeticWeldBeadSide_e: " & FeatureData.Side)

If FeatureData.FromToLength = False Then
            FeatureData.FromToLength = True
        End If
        Debug.Print("   from/to length properties enabled? " & FeatureData.FromToLength)
If FeatureData.FromToLength Then
            Debug.Print("   start weld at: " & FeatureData.FromToStartPoint)
"   weld length: " & FeatureData.FromToWeldLength)
"   reverse weld? " & FeatureData.FromToReverse)
End If
        If FeatureData.IntermittentWeld = False Then
            FeatureData.IntermittentWeld = True
        End If
        Debug.Print("   intermittent weld properties enabled? " & FeatureData.IntermittentWeld)
If FeatureData.IntermittentWeld Then
            If FeatureData.GapOrPitch Then
                Debug.Print("   intermittent weld gap: " & FeatureData.Gap)
"   intermittent weld length: " & FeatureData.IntermittentWeldLength)
                Debug.Print("   intermittent weld pitch: " & FeatureData.Pitch)
"   intermittent weld length: " & FeatureData.IntermittentWeldLength)
"   stagger welds if welding on both sides? " & FeatureData.Staggered)
End If
        End If

        WeldFolder = FeatureData.GetWeldBeadFolder

"weld bead properties:")
        WeldFolder.Material =
        Debug.Print("   weld material is " & WeldFolder.Material)
"   welding cost per unit mass: " & WeldFolder.CostPerUnitMass)
"   weld mass per unit length: " & WeldFolder.MassPerUnitLength)
"   number of weld passes: " & WeldFolder.NumberOfWeldPasses)
"   weld process: " & WeldFolder.Process)
"   welding time per unit length: " & WeldFolder.TimePerUnitLength)
"   total welding cost: " & WeldFolder.TotalCost)
"   total weld length: " & WeldFolder.TotalLength)
"   total weld mass: " & WeldFolder.TotalMass)
"   total number of welds: " & WeldFolder.TotalNumber)
"   total welding time: " & WeldFolder.TotalTime)

        boolstatus = myFeature.ModifyDefinition(FeatureData, Part,

End Sub

    Public swApp As SldWorks

End Class


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

Subject:   Feedback on Help Topics
Page:   Insert Cosmetic Weld Bead Example (VB.NET)
*   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:


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

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.