Hide Table of Contents

Insert Cavity Example (VB.NET)

This example shows how to insert a cavity in a mold base.

'------------------------------------------------------------------------------------
' Preconditions:
' 1. Create a new folder and copy public_documents\tutorial\molds\telephone.sldprt 
'    to that folder.
' 2. Click File > New > Part > OK to create a new part document.
'    a. Insert a sketch of a rectangle with a length of 240 mm and width of 350 mm.
'    b. Using the sketch, create a boss extrude feature with a depth of 160 mm.
'    c. Save the part as telephoneMoldBase.sldprt in the folder created in step 1.
' 3. Click File > New > Assembly > OK to create a new assembly document.
'    a. Click telephoneMoldBase in Part/Assembly to Insert in the PropertyManager page.
'    b. Click OK.
'    c. Click Insert Components on the Assembly toolbar, click Browse in
'       Part/Assembly to Insert, click telephone.sldprt located in the folder 
'       created in step 1, and click Open.
'    d. Drop telephone.sldprt in the graphics area.
'    e. Click View > Display > Hidden Lines Visible.
'    f. In the FeatureManager design tree, click telephone<1> and click Move Component
'       in the Assembly toolbar.
'    g. Move telephone<1> into the center of telephoneMoldBase<1> and click OK.
'       TIP: Change the view orientation to Top and Front to help center telephone<1>.
'    h. Click File > Save All > Rebuild and save the document (recommended)
'       navigate to the folder created in step 1, type AssemInterim.sldasm in 
'       File name, and click Save.
' 4. Click telephoneMoldBase<1> in the FeatureManager design tree.
' 5. Ctrl+click telephone<1> in the FeatureManager design tree.
'
' Postconditions:
' 1. Creates Cavity1 in telphoneMoldBase<1>.
' 2. Expand telephoneMoldBase<1> to verify step 1.
'-----------------------------------------------------------------------------------
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 swSelMgr As SelectionMgr
        Dim swAssy As AssemblyDoc
        Dim swMoldBaseComp As Component2
        Dim swCoreComp1 As Component2
        Dim nRetval As Integer
        Dim nInfo As Integer
        Dim bRet As Boolean
 
        swModel = swApp.ActiveDoc
        swAssy = swModel
 
        swSelMgr = swModel.SelectionManager
        swMoldBaseComp = swSelMgr.GetSelectedObjectsComponent2(1)
        swCoreComp1 = swSelMgr.GetSelectedObjectsComponent2(2)

        swModel.ClearSelection2(True)

        bRet = swMoldBaseComp.Select2(False, 0)
        nRetval = swAssy.EditPart2(TrueTrue, nInfo)
        bRet = swCoreComp1.Select2(True, 0)
        swAssy.InsertCavity4(0.0#, 0, 0.0#, True, swCavityScaleType_e.swAboutCentroid, 0)
        swAssy.EditAssembly()
 
    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:   Insert Cavity 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.