Hide Table of Contents

Mirror Pattern Feature Example (VBA)

This example shows how to mirror a pattern feature.

 

'*******************************************************************************

'

' Preconditions: A new part document is open.

'

' Postconditions: Two bodies, mirror plane, and chamfer feature are created

'                 Chamfer feature is mirrored from one body to another

'

' ******************************************************************************

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swSelMgr As SelectionMgr

Dim swFeatMgr As SldWorks.FeatureManager

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension

Set swSelMgr = swModel.SelectionManager

Set swFeatMgr = swModel.FeatureManager

 

Call CreateBodiesAndFeature

 

boolstatus = swModelDocExt.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 2, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Chamfer1", "BODYFEATURE", 0, 0, 0, True, 1, Nothing, 0)

swFeatMgr.InsertMirrorFeature2 False, True, False, False, swFeatureScope_e.swFeatureScope_SelectedBodiesWithAutoSelect

End Sub

 

Sub CreateBodiesAndFeature()

boolstatus = swModelDocExt.SelectByID2("Front Plane", "PLANE", -0.07123644442095, 0.0626824326557, -0.004995018808801, False, 0, Nothing, 0)

swModel.ClearSelection2 True

swModel.SketchRectangle -0.03870663771712, 0.03937630272953, 0, 0.0445996898263, -0.02705446650124, 0, 1

swModel.ShowNamedView2 "*Trimetric", 8

swModel.ClearSelection2 True

boolstatus = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Line1", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Line4", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Line3", "SKETCHSEGMENT", 0, 0, 0, True, 0, Nothing, 0)

swFeatMgr.FeatureExtrusion2 True, False, False, 0, 0, 0.02, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False

swSelMgr.EnableContourSelection = 0

boolstatus = swModelDocExt.SelectByID2("", "FACE", -0.01450930355037, 0.01645564156394, 0.01999999999998, True, 0, Nothing, 0)

swModel.CreatePlaneAtOffset3 0.03, False, True

swModel.ClearSelection2 True

boolstatus = swModelDocExt.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Extrude1", "SOLIDBODY", -0.01616769479756, 0.03631008029822, 0.01999999999992, True, 0, Nothing, 0)

swModel.ClearSelection2 True

boolstatus = swModelDocExt.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 2, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("Extrude1", "SOLIDBODY", -0.01616769479756, 0.03631008029822, 0.01999999999992, True, 256, Nothing, 0)

swFeatMgr.InsertMirrorFeature2 True, False, False, False, swFeatureScope_SelectedBodiesWithAutoSelect

boolstatus = swModelDocExt.SelectByID2("", "EDGE", -0.01592281338117, 0.03962412355071, 0.01983163419141, True, 0, Nothing, 0)

swFeatMgr.InsertFeatureChamfer 4, 1, 0.01, 0.7853981633975, 0, 0, 0, 0

End Sub



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:   Mirror Pattern Feature Example (VBA)
*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) 2013 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.