Hide Table of Contents

Create and Modify Closed Corner Feature Example (VB.NET)

This example shows how to create and modify a closed corner feature in a sheet metal part.


'------------------------------------------------------------------
' Preconditions:
' 1. Verify that the specified sheet metal part document to
'    open exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Opens the specified sheet metal part document.
' 2. Selects two faces.
' 3. Inserts a closed corner feature.
' 4. Modifies properties of the closed corner feature.
' 5. Examine the graphics area and Immediate window.
'
' NOTE: Because this part document 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 swFeature As Feature
        Dim swSelectionMgr As SelectionMgr
        Dim swClosedCornerFeatureData As ClosedCornerFeatureData
        Dim status As Boolean
        Dim errors As Integer
        Dim warnings As Integer
        Dim fileName As String
        Dim faces() As Object
        Dim swFace As Face2
        Dim i As Integer
 
        fileName = "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\sheetmetal\formtools\cover.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
        swModelDocExt = swModel.Extension
        swSelectionMgr = swModel.SelectionManager
 
        'Select the faces for the closed corner feature
        status = swModelDocExt.SelectByID2("""FACE", 0.0110595835492404, 0.0280018934407167, 0.0497348782814129, True, 1, Nothing, 0)
        status = swModelDocExt.SelectByID2("""FACE", 0.0181424245698736, 0.0110595835492404, 0.0495671179450028, True, 1073741824, Nothing, 0)
 
        'Insert the closed corner feature
        swModel.InsertSheetMetalClosedCorner()
 
        'Select the closed corner feature
        status = swModelDocExt.SelectByID2("Closed Corner1""BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
        swFeature = swSelectionMgr.GetSelectedObject6(1, -1)
        swClosedCornerFeatureData = swFeature.GetDefinition
 
        'Access closed corner feature
        status = swClosedCornerFeatureData.AccessSelections(swModel, Nothing)
        Debug.Print("Original properties: ")
        Debug.Print("  Corner type: " & swClosedCornerFeatureData.CornerType)
        Debug.Print("  Gap distance: " & swClosedCornerFeatureData.GapDistance)
        Debug.Print("  Open bend region? " & swClosedCornerFeatureData.OpenBendRegion)
        Debug.Print("  Overlap/underlap ratio: " & swClosedCornerFeatureData.OverlapUnderlapRatio)
        faces = swClosedCornerFeatureData.Faces
        For i = 0 To UBound(faces)
            swFace = faces(i)
            Debug.Print("  Area of face " & i & ": " & swFace.GetArea * 1000 & " mm")
        Next i
        Debug.Print("Modified properties: ")
        swClosedCornerFeatureData.CornerType = swClosedCornerTypes_e.swClosedCornerTypeUnderlap
        swClosedCornerFeatureData.GapDistance = 0.005
        swClosedCornerFeatureData.OpenBendRegion = True
        swClosedCornerFeatureData.OverlapUnderlapRatio = 0.5
        Debug.Print("  Corner type: " & swClosedCornerFeatureData.CornerType)
        Debug.Print("  Gap distance: " & swClosedCornerFeatureData.GapDistance)
        Debug.Print("  Open bend region? " & swClosedCornerFeatureData.OpenBendRegion)
        Debug.Print("  Overlap/underlap ratio: " & swClosedCornerFeatureData.OverlapUnderlapRatio)
 
        status = swFeature.ModifyDefinition(swClosedCornerFeatureData, swModel, Nothing)
 
    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 and Modify Closed Corner 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) 2015 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.