Hide Table of Contents

Insert Cosmetic Weld Bead Using Geometric Entities Example (VB.NET)

This example shows how to insert a cosmetic weld bead using geometric entities.

'----------------------------------------------
' Preconditions: 
' 1. Verify that the part to open exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Creates a cosmetic weld bead using the
'    selected geometric entities (i.e., faces).
' 2. To verify, examine the graphics area and
'    expand the Weld Folder and its subfolder
'    in the FeatureManager design tree.
' 3. Examine the Immediate window.
'
NOTE: Because the part document is used elsewhere,
' do not save any changes to it.
'-----------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
 
Partial Class SolidWorksMacro
 
    Public Sub Main()
 
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swFeature As Feature
        Dim swSelMgr As SelectionMgr
        Dim swFeatureMgr As FeatureManager
        Dim swCosmeticWeldBeadFeatureData As CosmeticWeldBeadFeatureData
        Dim status As Boolean
        Dim errors As Integer
        Dim warnings As Integer
        Dim fileName As String
        Dim entityType As Integer
 
        'Open model document
        fileName = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\driveworksxpress\leg.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
 
        'Select the faces
        swModelDocExt = swModel.Extension
        'From face
        status = swModelDocExt.SelectByID2("""FACE", 0.447611268878973, 0.185506718400291, 0.00676112086262037, True, 4, Nothing, 0)
        'To face
        status = swModelDocExt.SelectByID2("""FACE", 0.567647499089958, 0.0888999999998532, 0.00208831790428121, True, 8, Nothing, 0)
 
        swSelMgr = swModel.SelectionManager
        Dim weldFromFace(0) As Face2
        Dim weldFromArray(0) As Object
        weldFromFace(0) = swSelMgr.GetSelectedObject6(1, 4)
        weldFromArray = weldFromFace
 
        Dim weldToFace(0) As Face2
        Dim weldToArray(0) As Object
        weldToFace(0) = swSelMgr.GetSelectedObject6(1, 8)
        weldToArray = weldToFace
 
        'Create cosmetic weld bead using the selected faces
        Dim weldObjs(1) As Object
        swFeatureMgr = swModel.FeatureManager
        weldObjs = swFeatureMgr.InsertCosmeticWeldBead2(0, weldFromArray, weldToArray, 15 / 1000)
 
        'Get the weld-from and weld-to entities and their types
        status = swModelDocExt.SelectByID2("Weld Bead1""COSMETIC_WELD", 0, 0, 0, False, 0, Nothing, 0)
        swFeature = swSelMgr.GetSelectedObject6(1, -1)
        swCosmeticWeldBeadFeatureData = swFeature.GetDefinition
        swCosmeticWeldBeadFeatureData.AccessSelections(swModel, Nothing)
        Debug.Print(swFeature.Name)
        weldObjs = swCosmeticWeldBeadFeatureData.GetEntitiesWeldFrom(entityType)
        Debug.Print("  Weld-from type: " & entityType)
        weldObjs = swCosmeticWeldBeadFeatureData.GetEntitiesWeldTo(entityType)
        Debug.Print("  Weld-to type:   " & entityType)
        swCosmeticWeldBeadFeatureData.ReleaseSelectionAccess()
 
    End Sub
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    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

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