Hide Table of Contents

Insert Weldment End Cap Example (VBA)

This example shows how to create an end cap on the open face of a structural member.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open install_dir\samples\tutorial\api\weldment_box3.sldprt.
' 2. Open an Immediate window.
'
' Postconditions:
' 1. Deletes End cap1.
' 2. Inserts End cap3 in the FeatureManager design tree.
' 3. Inspect the Immediate window.
'
' NOTE: Because the model is used elsewhere, do not save changes.
' ---------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim myFeature As SldWorks.Feature
Dim Part As SldWorks.ModelDoc2
Dim swEndCap As SldWorks.EndCapFeatureData
Dim boolstatus As Boolean

Option Explicit
Sub main()

    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
   

    boolstatus = Part.Extension.SelectByID2("End cap1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
    Part.EditDelete
   

    Part.ViewZoomTo2 0.632542197290199, 0.972121141705638, 3.46184961022406E-02, 1.1852319686392, 0.619681287512073, 3.46184961022431E-02
   

    boolstatus = Part.Extension.SelectByID2("", "FACE", 0.58771345904097, 0.614999999999952, -1.01293869257864, True, 0, Nothing, 0)
    boolstatus = Part.Extension.SelectByID2("", "FACE", -1.24763445314215E-02, 0.614999999999839, -1.0014248149476, True, 0, Nothing, 0)
   
    Set myFeature = Part.FeatureManager.InsertEndCapFeature3(0.005, False, False, 0.003, 0.6, 0.003, True, 0.002, False, 2)

    Set swEndCap = myFeature.GetDefinition
 

    Debug.Print "File = " & Part.GetPathName
    Debug.Print "  " & myFeature.Name
    Debug.Print "    Chamfer distance or fillet radius                  = " & swEndCap.ChamferDistance * 1000# & " mm"
    Debug.Print "    Inset distance                                     = " & swEndCap.DepthDistance * 1000# & " mm"
    Debug.Print "    Thickness direction (0=outward, 1=inward, 2=inset) = " & swEndCap.IsEndCapInward
    Debug.Print "    Offset distance                                    = " & swEndCap.OffsetDistance * 1000# & " mm"
    Debug.Print "    Thickness of end cap                               = " & swEndCap.Thickness * 1000# & " mm"
    Debug.Print "    Thickness ratio for offset                         = " & swEndCap.ThicknessRatioForOffset
    Debug.Print "    Chamfer corners                                    = " & swEndCap.UseChamferCorners
    Debug.Print "    Apply corner treatment                             = " & swEndCap.UseCornerTreatment
    Debug.Print "    Reverse offset                                     = " & swEndCap.UseReverse
    Debug.Print "    Use thickness ratio for offset                     = " & swEndCap.UseThicknessRatioForOffset

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 Weldment End Cap 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) 2016 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.