Hide Table of Contents

Create Surface-sweep Feature Example (VB.NET)

This example shows how to create a surface-sweep feature.

'---------------------------------------------------
' Preconditions: Verify that the part template exists.
'
' Postconditions:
' 1. Opens a new part.
' 2. Creates two sketches.
' 3. Inserts a surface-sweep feature.
' 4. 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
 
    Public Sub main()
 
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swSketchManager As SketchManager
        Dim swSketchSegment As SketchSegment
        Dim swFeature As Feature
        Dim swFeatureManager As FeatureManager
        Dim status As Boolean
 
        'Open new part document
        swModel = swApp.NewDocument("C:\ProgramData\SolidWorks\SOLIDWORKS 2017\templates\part.prtdot", 0, 0, 0)
        swModelDocExt = swModel.Extension
 
        'Create a sketch
        swSketchManager = swModel.SketchManager
        swSketchManager.InsertSketch(True)
        status = swModelDocExt.SelectByID2("Front Plane""PLANE", 0, 0, 0, False, 0, Nothing, 0)
        swSketchSegment = swSketchManager.CreateLine(0.0#, 0.0#, 0.0#, 0.068491, 0.049604, 0.0#)
        swSketchSegment = swSketchManager.CreateLine(0.068491, 0.049604, 0.0#, 0.10923, 0.112837, 0.0#)
        swSketchSegment = swSketchManager.CreateLine(0.10923, 0.112837, 0.0#, 0.194652, 0.154023, 0.0#)
        swSketchManager.InsertSketch(True)
 
        swModel.ViewZoomtofit2()
        swModel.ShowNamedView2("*Isometric", 7)
        swModel.ClearSelection2(True)
 
        'Create another sketch
        status = swModelDocExt.SelectByID2("Right Plane""PLANE", 0, 0, 0, False, 0, Nothing, 0)
        swSketchManager.InsertSketch(True)
        swSketchSegment = swSketchManager.CreateLine(-0.0#, 0.0#, 0.0#, 0.021042, 0.091756, 0.0#)
        swSketchSegment = swSketchManager.CreateLine(0.021042, 0.091756, 0.0#, 0.098366, 0.085093, 0.0#)
        swSketchSegment = swSketchManager.CreateLine(0.098366, 0.085093, 0.0#, 0.143062, 0.122696, 0.0#)
        swModel.ClearSelection2(True)
        swSketchManager.InsertSketch(True)
 
        'Insert surface sweep
        status = swModelDocExt.SelectByID2("Sketch2""SKETCH", 0, 0, 0, False, 1, Nothing, 0)
        status = swModelDocExt.SelectByID2("Sketch1""SKETCH", 0, 0, 0, True, 4, Nothing, 0)
        swFeatureManager = swModel.FeatureManager
        swFeature = swFeatureManager.InsertSweepSurface3(False, 0, FalseFalse, 0, 0, 0, TrueTrue, 0, TrueFalse, 0, 0)
 
    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:   Create Surface-sweep 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.