Hide Table of Contents

Create Extrusion Feature Example (VB.NET)

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.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System

Partial Class SolidWorksMacro

    
Dim myFeature As Feature
    
Dim Part As ModelDoc2
    
Dim myRefPlane As RefPlane
    
Dim boolstatus As Boolean

    Sub main()

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

        boolstatus = Part.Extension.SelectByID2(
"Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
        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)
        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 Object
        vSkLines = Part.SketchManager.CreateCornerRectangle(-0.0250462141853123, 0.0157487558892494, 0, 0.0275128867944718, -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", 0.00105020593408751, -0.00195369982668282, 0.0248175428318827, True, 32, Nothing, 0)
        
' End condition reference
        boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0.0068370744701368, -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
        myFeature = Part.FeatureManager.FeatureExtrusion3(True, False, True, swEndConditions_e.swEndCondOffsetFromSurface, 0, 0.003, 0.003, False, False, False, False, 0.0174532925199433, 0.0174532925199433, False, False, False, False, True, True, True, swStartConditions_e.swStartSurface, 0, False)

    
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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Extrusion Feature 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) 2024 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.