Hide Table of Contents

Mirror Components Example (VBA)

This example shows how to mirror components in an assembly.

'----------------------------------------------------------------------------
' Preconditions: Open public_documents\samples\tutorial\advdrawings\98food processor.sldasm.
'
' Postconditions:
' 1. Inserts reference plane PLANE4.
' 2. Creates feature MirrorComponent1 that mirrors six assembly
'    components.
' 3. Saves the mirror components to files with file name suffix _TestMirror to
'    public_documents\samples\tutorial\advdrawings.
' 4. Examine public_documents\samples\tutorial\advdrawings, the FeatureManager design
'    tree, and the graphics area.
'
' NOTE: Because the assembly is used elsewhere, do not save changes.
'---------------------------------------------------------------------------

Option Explicit

Sub main()
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks   

    Dim swModel As SldWorks.ModelDoc2
    Set swModel = swApp.ActiveDoc   

    Dim boolstatus As Boolean
    boolstatus = swModel.Extension.SelectByID2("", "FACE", 0.104250921669188, -2.36987012272039E-04, -5.97199999999418E-02, True, 0, Nothing, 0)
    Dim myRefPlane As SldWorks.RefPlane
    Set myRefPlane = swModel.FeatureManager.InsertRefPlane(8, 0.01, 0, 0, 0, 0)   

    Dim swAssem As SldWorks.AssemblyDoc
    Set swAssem = swModel
   

    Dim compsToInstance As Object
    Set compsToInstance = Nothing   

    Dim filenames As Object
    Set filenames = Nothing   

    Dim location As String
    location = ""   

    Dim nameModifierType As swMirrorComponentNameModifier_e
    nameModifierType = swMirrorComponentName_Suffix
    Dim nameModifier As String
    nameModifier = "_TestMirror"   

    Dim mirrorPlane As SldWorks.Feature
    Set mirrorPlane = swAssem.FeatureByName("PLANE4")   

    Dim compsToMirror(0 To 5) As Object
    Set compsToMirror(0) = swAssem.GetComponentByName("gear- caddy-1")
    Set compsToMirror(1) = swAssem.GetComponentByName("middle-gear-1")
    Set compsToMirror(2) = swAssem.GetComponentByName("shaft gear-1")
    Set compsToMirror(3) = swAssem.GetComponentByName("middle-gear plate-1")
    Set compsToMirror(4) = swAssem.GetComponentByName("base plate-1")
    Set compsToMirror(5) = swAssem.GetComponentByName("shaft gear insert-1")   

    Dim orientations As Object
    Set orientations = Nothing   

    Dim orientAboutCoM As Boolean
    orientAboutCoM = True   

    Dim createDerivedConfigs As Boolean
    createDerivedConfigs = False   

    Dim importOptions As Long
    importOptions = swMirrorPartOptions_ImportSolids

    Dim breakLinks As Boolean
    breakLinks = False
    Dim preserveZAxis As Boolean
    preserveZAxis = True   

    Dim vResult As Variant
    vResult = swAssem.MirrorComponents3(mirrorPlane, compsToInstance, orientations, orientAboutCoM, (compsToMirror), createDerivedConfigs, filenames, nameModifierType, nameModifier, location, importOptions, breakLinks, preserveZAxis, True)
   

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 Components 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) 2020 SP01

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.