Hide Table of Contents

Enable Contour Selection Example (VBA)

This example shows how to select the contour of a sketch region and extrude the selected region.

'----------------------------------------------------------------------------
' Preconditions: Ensure that the specified document template exists.
'
' Postconditions: The selected sketch region is extruded.
' ---------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vSkLines As Variant
Dim boolstatus As Boolean

Option Explicit

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2014\templates\Part.prtdot", 0, 0, 0)
    Set swModel = swApp.ActiveDoc
    boolstatus = swModel.SetUserPreferenceToggle(swUserPreferenceToggle_e.swDisplayOrigins, True)
    swModel.ClearSelection2 True
   

    vSkLines = swModel.SketchManager.CreateCornerRectangle(-3.90769010920735E-02, 4.05984975017191E-02, 0, 1.29020232818107E-02, -1.66534302871355E-02, 0)
    swModel.ClearSelection2 True
    vSkLines = swModel.SketchManager.CreateCornerRectangle(-7.51826843645631E-03, 1.56092594749566E-02, 0, 4.87922329685375E-02, -0.041704950991857, 0)
    swModel.ClearSelection2 True
    swModel.SketchManager.InsertSketch True
   

    ' Enable contour selection
    swModel.SelectionManager.EnableContourSelection = True
    ' Select a contour to extrude
    swModel.Extension.SelectByID2 "Sketch1", "SKETCHREGION", 0, 0.01, 0, True, 4, Nothing, 0
    swModel.FeatureManager.FeatureExtrusion3 True, False, False, 0, 0, 0.01, 0.01, False, False, False, False, 0, 0, False, False, False, False, True, True, True, 0, 0, False
    ' Disable contour selection
    swModel.SelectionManager.EnableContourSelection = False
    swModel.ClearSelection2 True

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:   Enable Contour Selection 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) 2022 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.