Hide Table of Contents

Get Mirror Solid Feature Data Example (VBA)

This example shows how to get mirror solid feature data.

 

'----------------------------------------

'

' Preconditions:

'       (1) Model document is open.

'       (2) Mirror solid feature is selected.

'

' Postconditions: None

'

'-----------------------------------------

Option Explicit

Public Enum swSelectType_e

    swSelFACES = 2                  '  "FACE"

    swSelDATUMPLANES = 4            '  "PLANE"

    swSelREFSURFACES = 27           '  "REFSURFACE"

End Enum

Public Enum swBodyType_e

    swAllBodies = -1

    swSolidBody = 0

    swSheetBody = 1

    swWireBody = 2

    swMinimumBody = 3

    swGeneralBody = 4

    swEmptyBody = 5

End Enum

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swSelMgr                As SldWorks.SelectionMgr

    Dim swSelData               As SldWorks.SelectData

    Dim swFeat                  As SldWorks.feature

    Dim swMirrorSolid           As SldWorks.MirrorSolidFeatureData

    Dim swBody                  As SldWorks.body2

    Dim swFace                  As SldWorks.face2

    Dim swRefPlane              As SldWorks.refPlane

    Dim swEnt                   As SldWorks.Entity

    Dim swFaceFeat              As SldWorks.feature

    Dim swRefPlaneFeat          As SldWorks.RefPlaneFeatureData

    Dim vPlaneParam             As Variant

    Dim vBody                   As Variant

    Dim i                       As Long

    Dim bRet                    As Boolean

    

    Set swApp = CreateObject("SldWorks.Application")

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swSelData = swSelMgr.CreateSelectData

    Set swFeat = swSelMgr.GetSelectedObject5(1)

    Set swMirrorSolid = swFeat.GetDefinition

    

    ' Disable Visual Basic error on Query Interface

    On Error Resume Next

    

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print "  " & swFeat.Name

    Debug.Print "    PatternBodyCount   = " & swMirrorSolid.GetPatternBodyCount

    Debug.Print "    Merge              = " & swMirrorSolid.Merge

    Debug.Print "    KnitSurface        = " & swMirrorSolid.KnitSurface

    

    ' Roll back to get to the faces and features

    bRet = swMirrorSolid.AccessSelections(swModel, Nothing): Debug.Assert bRet

    

    

    ' Face or reference surface

    Set swFace = swMirrorSolid.Face

    Set swEnt = swMirrorSolid.Face

    

    ' Reference plane

    Set swFaceFeat = swMirrorSolid.Face

    Set swRefPlane = swFaceFeat.GetSpecificFeature

    Set swRefPlaneFeat = swFaceFeat.GetDefinition

    

    ' Reference plane also presents Entity interface

    Debug.Assert Not swEnt Is Nothing

    Debug.Print "    Face Type          = " & swEnt.GetType

    

    swModel.ClearSelection2 True

    If Not swFaceFeat Is Nothing Then

        Debug.Print "    Feat Type          = " & swFaceFeat.GetTypeName

        

        bRet = swFaceFeat.Select2(True, 0)

    Else

        bRet = swEnt.Select4(True, swSelData)

    End If

    Debug.Assert bRet

    If bRet Then Stop

    

    

    swModel.ClearSelection2 True

    vBody = swMirrorSolid.PatternBodyArray

    For i = 0 To UBound(vBody)

        Set swBody = vBody(i)

        

        bRet = swBody.Select(True, 0): Debug.Assert bRet

        

        Debug.Print "    Body(" & i & ")            = " & swBody.GetType

    Next i

    If bRet Then Stop

    

    

    ' Update feature

     bRet = swFeat.ModifyDefinition(swMirrorSolid, swModel, Nothing): Debug.Assert bRet

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:   Get Mirror Solid Data 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) 2014 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.