Hide Table of Contents

Get Mirror Part Information Example (VBA)

This example shows how to get information about a mirror part.

' Preconditions:
' 1. Open a part that contains a reference plane about which to mirror the part.
' 2. Select the reference plane in the FeatureManager design tree.
' Postconditions:
' 1. A part mirrored about the selected reference plane is created.
' 2. The reference plane is visible in the graphics area.
' 3. Inspect the Immediate window for mirror part feature data.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim selMgr As SldWorks.SelectionMgr
Dim swPart As SldWorks.PartDoc
Dim mirrorFeature As SldWorks.Feature
Dim myFeature As SldWorks.Feature
Dim resultPart As SldWorks.ModelDoc2
Dim mirrorFeatData As SldWorks.MirrorPartFeatureData
Dim refPlane As SldWorks.refPlane
Dim facePlane As SldWorks.Face2
Dim mirrorOptions  As Long
Dim faceType As Long
Dim selType As swSelectType_e
Dim message As String

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc

    If swModel Is Nothing Then Exit Sub
    If swModel.GetType <> swDocPART Then Exit Sub

    Set selMgr = swModel.SelectionManager

    If selMgr.GetSelectedObjectCount2(-1) = 0 Then Exit Sub

    selType = selMgr.GetSelectedObjectType3(1, -1)
    If Not (selType = swSelDATUMPLANES Or selType = swSelFACES) Then Exit Sub

    Set swPart = swModel

    mirrorOptions = swMirrorPartOptions_ImportSolids + _
                    swMirrorPartOptions_ImportCustomProperties + _

    Set mirrorFeature = swPart.MirrorPart2(False, mirrorOptions, resultPart)

    If mirrorFeature Is Nothing Then
        message = "No Feature"
        message = "Feature: " & mirrorFeature.Name
    End If

    If resultPart Is Nothing Then
        Debug.Print "No new part. " & message
        Debug.Print resultPart.GetTitle & ". " & message
    End If

    Set swModel = swApp.ActiveDoc
    Set selMgr = swModel.SelectionManager
    mirrorFeature.Select2 False, -1

    Set myFeature = selMgr.GetSelectedObject6(1, -1)
    Set mirrorFeatData = myFeature.GetDefinition

    mirrorFeatData.AccessSelections swModel, Nothing

    Debug.Print "  Path name = " & mirrorFeatData.PathName
    Debug.Print "  Import surface bodies? = " & mirrorFeatData.SurfaceBodies
    Debug.Print "  Import solid bodies? = " & mirrorFeatData.SolidBodies
    Debug.Print "  Import custom properties? = " & mirrorFeatData.CustomProperties
    Debug.Print "  Import cut-list properties? = " & mirrorFeatData.CutListProperties

    faceType = mirrorFeatData.GetMirrorPlaneType
    Debug.Print "  Mirror plane type as defined in swMirrorPlaneType_e = " & faceType

    Dim plane As SldWorks.Entity
    If faceType = 1 Then
        Set refPlane = mirrorFeatData.GetMirrorPlane
        Set plane = refPlane
        plane.Select False
        Set facePlane = mirrorFeatData.GetMirrorPlane
        Set plane = facePlane
        plane.Select False
    End If

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

Subject:   Feedback on Help Topics
Page:   Get Mirror Part Information Example (VBA)
*   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:


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

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.