Hide Table of Contents

Create Extrusion Feature Example (VBA)

This example shows how to create an extrusion feature.

'----------------------------------------------------------------------------
' Preconditions: Verify that the specified part template exists.
'
' Postconditions:
' 1. Creates a Boss-Extrude1 feature.
' 2. Examine the FeatureManager design tree and graphics area.
' ---------------------------------------------------------------------------
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim myFeature As SldWorks.Feature
Dim Part As SldWorks.ModelDoc2
Dim myRefPlane As SldWorks.RefPlane
Dim boolstatus As Boolean


Sub main()

    Set swApp = Application.SldWorks
   

    Set Part = swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2016\templates\Part.prtdot", 0, 0, 0)
    Set Part = swApp.ActiveDoc
   

    boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
    Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, 0.01, 0, 0, 0, 0)
    boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
    Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, 0.02, 0, 0, 0, 0)

    boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
    Dim vSkLines As Variant
    vSkLines = Part.SketchManager.CreateCornerRectangle(-2.50462141853123E-02, 1.57487558892494E-02, 0, 2.75128867944718E-02, -0.015559011842391, 0)

    Part.SketchManager.InsertSketch True
   

    ' Sketch to extrude
    boolstatus = Part.Extension.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
    ' Start condition reference
    boolstatus = Part.Extension.SelectByID2("Plane2", "PLANE", 1.05020593408751E-03, -1.95369982668282E-03, 2.48175428318827E-02, True, 32, Nothing, 0)
    ' End condition reference
    boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 6.8370744701368E-03, -0.004419862088339, 0.018892268568016, True, 1, Nothing, 0)
   

    ' Boss extrusion start condition reference is Plane2, and the extrusion end is offset 3 mm from the end condition reference, Plane1
    Set myFeature = Part.FeatureManager.FeatureExtrusion3(True, False, True, swEndCondOffsetFromSurface, 0, 0.003, 0.003, False, False, False, False, 1.74532925199433E-02, 1.74532925199433E-02, False, False, False, False, True, True, True, swStartSurface, 0, False)

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:   Create Extrusion Feature 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) 2017 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.