Hide Table of Contents

Insert Reference Plane Example (VBA)

This example shows how to create a constraint-based, angle, reference plane.

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

' Preconditions:

' 1. Specified file exists on your system.

' 2. Run the macro (press F5).

' 3. Examine the Immediate window to find out the type of

'   reference plane created.

'

' Postconditions: Constraint-based reference plane is created.

'

' NOTE: Because the specified SOLIDWORKS document is

'       used in a SOLIDWORKS online tutorial, do not

'       save any changes when closing the document,

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

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swFeatureManager As SldWorks.FeatureManager

Dim swFeature As SldWorks.Feature

Dim swRefPlane As SldWorks.RefPlane

Dim swSelMgr As SldWorks.SelectionMgr

Dim swRefPlaneFeatureData As SldWorks.RefPlaneFeatureData

Dim fileerror As Long

Dim filewarning As Long

Dim boolstatus As Boolean

Dim planeType As Long

 

Sub main()

 

Set swApp = Application.SldWorks

swApp.OpenDoc6 "c:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\samples\tutorial\api\plate.sldprt", swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning

Set swModel = swApp.ActiveDoc

Set swModelDocExt = swModel.Extension

Set swFeatureManager = swModel.FeatureManager

Set swSelMgr = swModel.SelectionManager

 

' Create a constraint-based reference plane

boolstatus = swModelDocExt.SelectByID2("", "FACE", 0.028424218552, 0.07057725774359, 0, True, 0, Nothing, 0)

boolstatus = swModelDocExt.SelectByID2("", "EDGE", 0.05976462601598, 0.0718389621656, 1.242036435087E-04, True, 1, Nothing, 0)

Set swRefPlane = swFeatureManager.InsertRefPlane(16, 0.7853981633975, 4, 0, 0, 0)

 

' Get type of the just-created reference plane

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

Set swFeature = swSelMgr.GetSelectedObject6(1, -1)

Set swRefPlaneFeatureData = swFeature.GetDefinition

planeType = swRefPlaneFeatureData.Type2

Debug.Print "Type of reference plane using IRefPlaneFeatureData::Type2: "

Select Case planeType

    Case 0

        Debug.Print "  Invalid"

    Case 1

        Debug.Print "  Undefined"

    Case 2

        Debug.Print "  Line Point"

    Case 3

        Debug.Print "  Three Points"

    Case 4

        Debug.Print "  Line Line"

    Case 5

        Debug.Print "  Distance"

    Case 6

        Debug.Print "  Parallel"

    Case 7

        Debug.Print "  Angle"

    Case 8

        Debug.Print "  Normal"

    Case 9

        Debug.Print "  On Surface"

    Case 10

        Debug.Print "  Standard"

    Case 11

        Debug.Print "  Constraint-based"

    End Select

        Debug.Print ""

 

planeType = swRefPlaneFeatureData.Type

Debug.Print "Type of reference plane using IRefPlaneFeatureData::Type: "

Select Case planeType

    Case 0

        Debug.Print "  Invalid"

    Case 1

        Debug.Print "  Undefined"

    Case 2

        Debug.Print "  Line Point"

    Case 3

        Debug.Print "  Three Points"

    Case 4

        Debug.Print "  Line Line"

    Case 5

        Debug.Print "  Distance"

    Case 6

        Debug.Print "  Parallel"

    Case 7

        Debug.Print "  Angle"

    Case 8

        Debug.Print "  Normal"

    Case 9

        Debug.Print "  On Surface"

    Case 10

        Debug.Print "  Standard"

    Case 11

        Debug.Print "  Constraint-based"

    End Select

        Debug.Print ""

 

swModel.ClearSelection2 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:   Insert Reference Plane 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) 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.