Hide Table of Contents

Create Solid Body Surface Trim Feature Example (VB.NET)

This example shows how to create a solid body surface trim feature.

'---------------------------------------------------------------
' Preconditions:
' 1. Verify that the specified part to open exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Opens the specified part.
' 2. Creates Surface-Trim1.
' 3. Expand and examine Solid Bodies(1) in the FeatureManager 
'    design tree and examine the Immediate window.
'
' NOTE: Because the model is used elsewhere, do not save changes.
'----------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
 
Partial Class SolidWorksMacro
 
    Public Sub main()
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swFeatureManager As FeatureManager
        Dim swFeature As Feature
        Dim status As Boolean
        Dim fileName As String
        Dim errors As Integer
        Dim warnings As Integer
 
        fileName = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2017\tutorial\api\SurfaceTrimFeature.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
        swModelDocExt = swModel.Extension
        swFeatureManager = swModel.FeatureManager
 
        ' Select surface features
        status = swModelDocExt.SelectByID2("""SURFACEBODY", -0.0446486526100784, 0.0218350174377093, 0.0123754341749418, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2("""SURFACEBODY", -0.00815686270678384, 0.0415839719953865, 0.0242402652081068, True, 0, Nothing, 0)
 
        ' Select trimming surfaces to create solid body surface trim feature
        status = swFeatureManager.PreTrimSurface(TrueTrueFalseTrue)
        status = swModelDocExt.SelectByID2("""SURFACEBODY", 0.0059504253577245, 0.0413800871671199, 0.0248740287174201, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2("""SURFACEBODY", -0.037205042299604, 0.0343527327176432, 0.0123446167727934, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2("""SURFACEBODY", -0.0104497983190015, -0.047217217677548703, 0.0233436625590571, True, 0, Nothing, 0)
        Debug.Print("Solid body surface trim feature? " & swFeatureManager.SolidForTrim)
        swFeatureManager.SolidForTrim = True
        Debug.Print("Solid body surface trim feature? " & swFeatureManager.SolidForTrim)
        swFeature = swFeatureManager.PostTrimSurface(True)
 
    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 Solid Body Surface Trim 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) 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.